pybindgen icon indicating copy to clipboard operation
pybindgen copied to clipboard

PyInit_ on Windows requires dllexport

Open rcoreilly opened this issue 3 years ago • 0 comments

To get my app to work on Windows, I had to fix the generated .c file to add the usual annoying __declspec(dllexport) thing for the PyInit function. I'm surprised this hasn't come up before! I gather there is a _wrap_ macro that should be used for this.

in module.py:841:

    #define MOD_INIT(name) PyObject* PyInit_##name(void)

needs to be wrapped or conditionally have the __declspec(dllexport) added for windows:

    #define MOD_INIT(name) PyObject* __declspec(dllexport) PyInit_##name(void)

I'm not using version 2 but probably that has the same issue?

This is for https://github.com/go-python/gopy -- using pybindgen to access Go from python. Thanks!

rcoreilly avatar Aug 30 '21 07:08 rcoreilly