[Python-Dev] Is __declspec(dllexport) really needed on Windows?
Mark Hammond
mhammond@skippinet.com.au
Fri, 19 Jul 2002 09:15:46 +1000
Fredrik:
> greg wrote:
>
> > Someone told me that Pyrex should be generating
> > __declspec(dllexport) for the module init func.
>
> almost; for portability, it's better to use the DL_EXPORT
> provided by Python.h:
>
> DL_EXPORT(void)
> init_module(void)
> {
> ...
> }
>
> > But someone else says this is only needed if
> > you're importing a dll as a library, and that
> > it's not needed for Python extensions.
FWIW, www.python.org/sf/566100 deprecates DL_IMPORT/DL_EXPORT as it is
broken! Once this patch is checked in, the new blessed way to declare your
function will be:
PyMODINIT_FUNC init_module(void)
{
...
}
This macro will do the right thing in all situations and for all platforms.
It even provides the 'extern "C"' if your extension is in a C++ module.
The-patch-even-updates-the-doc ly,
Mark.