Can anyone help me with Python/C API?
I try to use Python/C API in my C++ app. And i have problems with code below:
- Code: Select all
int main(int , char **)
PyRun_SimpleString("from time import time,ctime\n"
"print ('Today is', ctime(time()))\n");
FILE* fp = fopen("c:/test.pyc", "wb");
if (fp != NULL)
long mn = PyImport_GetMagicNumber();
PyMarshal_WriteLongToFile(mn, fp, Py_MARSHAL_VERSION);
I compile this example in Win XP SP3(32bit) with mingw4.8-32bit (and I also tried VS2010 - same result) and it compiles successfully. When I try to run my app it fails when call PyMarshal_WriteLongToFile. What am I doing wrong? I tried to use Python 2.6, 2.7 and 3.3 - same problem...