[C++-sig] win32: BOOST_PYTHON_MODULE always exports DLL symbols

Nicolas Lelong n_lelong at hotmail.com
Thu Jan 2 18:19:54 CET 2003


>
> Add -DBOOST_PYTHON_STATIC_LIB to your compiler command-line or
> <define>BOOST_PYTHON_STATIC_LIB to your bjam requirements; that will
> turn off exporting.
>

I may make a big mistake but I've defined this symbol and this does not
change anything.
In fact, when reading 'config.hpp', we can find the only entry of
BOOST_PYTHON_STATIC_LIB:

#ifdef BOOST_PYTHON_STATIC_LIB
# define BOOST_PYTHON_STATIC_LINK
# elif !defined(BOOST_PYTHON_DYNAMIC_LIB)
# define BOOST_PYTHON_DYNAMIC_LIB
#endif

This conditions the declaration of the BOOST_PYTHON_DECL symbol to either
__declspec(dllexport) or __declspec(dllimport) or _nothing_. I'm OK with
that.

The 'problem' I have is with BOOST_PYTHON_MODULE_INIT in 'module_init.hpp'
that always define (for win32) the init##name function as [cut & paste] :

# if defined(_WIN32) || defined(__CYGWIN__)
# define BOOST_PYTHON_MODULE_INIT(name) \
void init_module_##name(); \
extern "C" __declspec(dllexport) void init##name() \
[...]

I can see no way for BOOST_PYTHON_STATIC_LIB to control the 'init##name'
declaration.
In fact, I think that this definition could be changed to :

# if defined(_WIN32) || defined(__CYGWIN__)
# define BOOST_PYTHON_MODULE_INIT(name) \
void init_module_##name(); \
extern "C" BOOST_PYTHON_DECL void init##name() \
[...]

But in this case, having BPL as a static lib (with BOOST_PYTHON_STATIC_LIB
defined) will prevent from being able to create DLL modules. In my local
modifications, I started having a symbol BOOST_PYTHON_EXTEND_EMBEDDED that
allowed me to explicitly tune the BPL code for my specific purpose of
extending an embedded python (such as disabling all dll exports, mainly) -
but maybe i missed something. Any thoughts?

Thanks,
Nicolas.




More information about the Cplusplus-sig mailing list