Boost logo

Boost :

Subject: Re: [boost] [config] Request for BOOST_SYMBOL_IMPORT_VISIBLE ?
From: Mostafa (mostafa_working_away_at_[hidden])
Date: 2011-02-07 05:34:22


On Sat, 29 Jan 2011 08:47:46 -0800, John Maddock <boost.regex_at_[hidden]>
wrote:

> I think this is a real problem, but the solution is rather cumbersome -
> a Boost library header would then have to support:
>
> 1) Exporting from dll.
> 2) Importing to executable.
> 3) Importing to dll and re-exporting.
> 4) None of the above (static lib).

I agree, for the sake of completeness, I would expand the above list to:

1) Export from dll.
2) Import to dll.
3) Export from static lib.
4) Import to static lib.
5) Import to executable.

I believe that the above covers the set of all possible imports/exports
for all binary entities that Boost would be interested in. As an aside,
even though I don't know of any compiler that requires 4) and 5), I
included it just in case.

The 5 requirements will then need to be replicated for cases where
compilers differ in their handling of symbols, for example, in the case of
exceptions and gcc. This may at first seem like a lot of macros, but they
are rather fine grained, more coarser helper macros along the lines of the
following could be provided:

//Pseudo-code

#define BOOST_IMPORT_EXPORT(client_api_name) \
     #ifdef client_api_name ## EXPORT_FROM_DLL \
     #define client_api_name BOOST_EXPORT_FROM_DLL \
     #elif defined client_api_name ## IMPORT_TO_DLL \
     #define client_api_name BOOST_IMPORT_TO_DLL \
     #elif defined client_api_name ## EXPORT_FROM_STATIC \
     #define client_api_name BOOST_EXPORT_FROM_STATIC \
     #elif defined client_api_name ## IMPORT_TO_STATIC \
     #define client_api_name BOOST_IMPORT_TO_STATIC \
     #elif defined client_api_name ## IMPORT_TO_EXE \
     #define client_api_name BOOST_IMPORT_TO_EXE \
     #else \
     #error No appropriate client_api_name macro defined! \
     #endif

Analogously, BOOST_IMPORT_EXPORT_EXCEPTION(client_api_name) would be
defined in the same manner.

And their usage would look like:

BOOST_IMPORT_EXPORT(MY_API)
BOOST_IMPORT_EXPORT_EXCEPTION(MY_API)

class MY_API Shape {};
MY_API void foo();
class MY_API_EXCEPTION GeoEx {};
etc...

Thoughts? Would anybody be interested in something like this?

Mostafa


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk