Win7 x64,Python3.3 32 位,Visual Studio 2010/2012(相同的行为)。以下代码编译并运行良好(即打印当前日期):
extern "C"{ // not having it doesn't make any difference either
#include <Python.h>
}
int main() {
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\n"
"print('Today is', ctime(time()))\n");
Py_Finalize();
return 0;
}
The application was unable to start correctly (0xc0000005). Click OK to close the application.
虽然这里失败并在执行之前显示 MessageBox main
(因此没有断点可能)。
extern "C"{ // not having it doesn't make any difference either
#include <Python.h>
}
int main() {
Py_Initialize();
PyObject *p = PyUnicode_FromString("test");
Py_Finalize();
return 0;
}