[Python-Dev] Is __declspec(dllexport) really needed on Windows?

Fredrik Lundh fredrik@pythonware.com
Thu, 18 Jul 2002 21:37:09 +0200


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.

that someone is confused; the dllexport declaration makes
sure that the init function is exported from the DLL.  if not,
Python's PYD loader won't find the init function.

</F>