Can I use MinGW compiled Python extensions together with Visual C++ compiled ones?

强颜欢笑 提交于 2019-12-14 03:09: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:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!