Boost logo

Boost :

From: jorg.schaible_at_[hidden]
Date: 2000-01-27 05:20:17


>..
>
># if defined BOOST_DECL_EXPORTS
># define BOOST_DECL __declspec(dllexport)
># else
># define BOOST_DECL __declspec(dllimport)
># endif
>
>These lines must be repeated for all compilers that support building
DLL's. I am
>not aware of any current (!) compiler that allows to build DLL's
without knowing
>this syntax. Even the gcc for Windows or latest IBM OS/2 compiler
(if I remember
>correctly) support it and either the lines have to be aded for the
gcc too or
>they should be moved out of scope of the compiler specific parts. I
request the
>latter just to "limit the complexity of config.hpp".

Hum... Is that really true? What about compilers that don't support
building DLL's, or support them but are building from a static
library at the moment? Shouldn't BOOST_DECL be null in that case?

--Beman

Hi Beman,

as you stated you must have definately 3 states for BOOST_DECL:

1) builing a DLL you have to declare it __declspec(dllexport)
2) building an application using the dynamic runtime you have to declare it
__declspec(dllimport)
3) building an application with static runtime or building a static library you
have to declare it to nothing (otherwise the linker may create an import library
for your application ... <g>)

With the MSVC I may declare

# if defined BOOST_DECL_EXPORTS
# define BOOST_DECL __declspec(dllexport)
# else
# if defined _DLL
# define BOOST_DECL __declspec(dllimport)
# else
# define BOOST_DECL
# endif
# endif

The problem is that compiler specific _DLL macro MSVC declares for case 2. I am
not aware of a similar one for the gcc or Borland C++. So I suppose we use
different defaults for the platform/compiler combinations and suggest two macros
BOOST_IMPORT and BOOST_NO_IMPORT. So the config.hpp would look something like:

# if defined __GNUC__
# ...
# if !defined BOOST_NO_IMPORT
# define BOOST_NO_IMPORT
# endif
# elif defined __SUNPRO_CC
# ...
# if !defined BOOST_NO_IMPORT
# define BOOST_NO_IMPORT
# endif
# elif defined __MWERKS__
# ...
# if !defined BOOST_NO_IMPORT
# define BOOST_IMPORT
# endif
# elif defined _MSC_VER && !defined __ICL
# ...
# if defined _DLL
# define BOOST_IMPORT
# endif
# endif

# if defined BOOST_DECL_EXPORTS
# define BOOST_DECL __declspec(dllexport)
# else
# if defined BOOST_IMPORT
# define BOOST_DECL __declspec(dllimport)
# else
# define BOOST_DECL
# endif
# endif

Using this schema you are able to set BOOST_NO_IMPORT in your makefile
independend of the platform you're current compiling on. Declaring nothing you
will import the libraries to your application (using DLL's is the default for
Windows and OS/2), UNIX does not care either.

Regards,
Jörg

BTW: Add the BOOST_DECL to the boost headers, e.g. for the timer class I already
added the declaration myself.


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