Can I use MinGW compiled Python extensions togethe

2019-08-31 07:20发布

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条回答
Emotional °昔
2楼-- · 2019-08-31 07:25

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™.

查看更多
登录 后发表回答