[Python-Dev] Is __declspec(dllexport) really needed on Windows?
M.-A. Lemburg
mal@lemburg.com
Thu, 18 Jul 2002 21:35:01 +0200
Greg Ewing wrote:
> Someone told me that Pyrex should be generating
> __declspec(dllexport) for the module init func.
> 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.
>
> Can anyone who knows what they're doing on
> Windows give me a definitive answer about
> whether it's really needed or not?
You need to export at least the init<modulename>()
API and that is usually done using the dllexport
flag.
Note that this is only needed for shared modules
(DLLs), not modules which are linked statically.
This is what I use for this:
/* Macro to "mark" a symbol for DLL export */
#if (defined(_MSC_VER) && _MSC_VER > 850 \
|| defined(__MINGW32__) || defined(__CYGWIN) || defined(__BEOS__))
# ifdef __cplusplus
# define MX_EXPORT(type) extern "C" type __declspec(dllexport)
# else
# define MX_EXPORT(type) extern type __declspec(dllexport)
# endif
#elif defined(__WATCOMC__)
# define MX_EXPORT(type) extern type __export
#elif defined(__IBMC__)
# define MX_EXPORT(type) extern type _Export
#else
# define MX_EXPORT(type) extern type
#endif
--
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting: http://www.egenix.com/
Python Software: http://www.egenix.com/files/python/