问题
Having trouble compiling a Python extension under Windows, I've asked a question.One of the answers does not answer my question but is worth asking as a question on its own.
Given a Visual C++ compiled Python distribution under Windows, would I have any problems if I use Visual C++ compiled extensions along with MinGW compiled ones?
This would allow me resort to MinGW when it is easier than configuring MS compiler.
回答1:
It's not officially supported, but I think it should work. Python exposes extern "C"
functions (with C linkage), so you should be able to call them from MSVC. But that's only Python itself. What about extensions? PyMODINIT_FUNC
also has extern "C"
in it, so that allows to call it from MSVC, too. Functions that you pass to Python by function pointer should also work, because they use cdecl
calling convention by default, but do not need C linkage (or C name mangling) because they are called by pointer. To sum up, it should Just Work™.
来源:https://stackoverflow.com/questions/20710532/can-i-use-mingw-compiled-python-extensions-together-with-visual-c-compiled-one