Cコードからpython関数を呼び出そうとしていますが、ここからサンプルをたどりました
また、正しいインクルード ファイル ディレクトリ、ライブラリ ディレクトリ、および python32.lib のリンク (python 32 を使用) がありますが、エラーは、PyString_FromString、PyInt_FromLong、PyInt_AsLong などの python/C API が定義されていないことでした (デバッガーのエラー)。
私は他のAPIも使用しているので、これは奇妙ですが、それらはすべて問題ありません...
ここで問題は何ですか??
int
main(int argc, char *argv[])
{
PyObject *pName, *pModule, *pDict, *pFunc;
PyObject *pArgs, *pValue;
int i;
if (argc < 3) {
fprintf(stderr,"Usage: call pythonfile funcname [args]\n");
return 1;
}
Py_Initialize();
pName = PyString_FromString(argv[1]);
/* Error checking of pName left out */
pModule = PyImport_Import(pName);
Py_DECREF(pName);
if (pModule != NULL) {
pDict = PyModule_GetDict(pModule);
/* pDict is a borrowed reference */
Py_Initialize()、PyImport_Import()、PyModule_GetDict() はすべて正常に動作しますが、PyString_FromString では動作しません...