
In order to export class from dynamic library one needs to add something as: __declspec(dllexport) wrapped in a macro. (Win32 example.) Right now libraries define their own macros, e.g Iostreams has BOOST_IO_DECL and Regex uses BOOST_REGEX_DECL. There could be more. I suggest common macro, BOOST_DECL to be used Boost-wide. Its value may be by default empty or deduced from BOOST_ALL_DYN_LINK as it is done in Regex. /Pavel

"Pavel Vozenilek" <pavel_vozenilek@hotmail.com> writes:
In order to export class from dynamic library one needs to add something as:
__declspec(dllexport)
wrapped in a macro. (Win32 example.)
Right now libraries define their own macros, e.g Iostreams has BOOST_IO_DECL and Regex uses BOOST_REGEX_DECL. There could be more.
I suggest common macro, BOOST_DECL to be used Boost-wide.
Its value may be by default empty or deduced from BOOST_ALL_DYN_LINK as it is done in Regex.
It may be important to link a static version of one library with a dynamic version of another. That wouldn't be possible with a single macro. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

"David Abrahams" <dave@boost-consulting.com> wrote in message news:ud60tozt9.fsf@boost-consulting.com...
"Pavel Vozenilek" <pavel_vozenilek@hotmail.com> writes:
Right now libraries define their own macros, e.g Iostreams has BOOST_IO_DECL and Regex uses BOOST_REGEX_DECL.
I suggest common macro, BOOST_DECL to be used Boost-wide.
Its value may be by default empty or deduced from BOOST_ALL_DYN_LINK as it is done in Regex.
It may be important to link a static version of one library with a dynamic version of another. That wouldn't be possible with a single macro.
What would be nice is a macro BOOST_DECLSPEC(xxx) which expands to 1. __declspec(dllexport) if a. BOOST_HAS_DECLSPEC are BOOST_xxx_SOURCE defined AND b. one of BOOST_ALL_DYN_LINK and BOOST_xxx_DYN_LINK is defined 2. __declspec(dllimport) if a. BOOST_HAS_DECLSPEC is defined b. BOOST_xxx_SOURCE is not defined c. one of BOOST_ALL_DYN_LINK and BOOST_xxx_DYN_LINK is defined 3. nothing, otherwise. Paul Mensonides once sent me some code which does a much simple version of the above, but it included four headers from Boost.PP and was 29 lines long. If such a macro can be defined in a self-contained manner and reasonably succintly I think it would be a big improvement over the current situation. Jonathan

"Jonathan Turkanis" <technews@kangaroologic.com> writes:
"David Abrahams" <dave@boost-consulting.com> wrote in message news:ud60tozt9.fsf@boost-consulting.com...
"Pavel Vozenilek" <pavel_vozenilek@hotmail.com> writes:
Right now libraries define their own macros, e.g Iostreams has BOOST_IO_DECL and Regex uses BOOST_REGEX_DECL.
I suggest common macro, BOOST_DECL to be used Boost-wide.
Its value may be by default empty or deduced from BOOST_ALL_DYN_LINK as it is done in Regex.
It may be important to link a static version of one library with a dynamic version of another. That wouldn't be possible with a single macro.
What would be nice is a macro BOOST_DECLSPEC(xxx) which expands to
1. __declspec(dllexport) if
a. BOOST_HAS_DECLSPEC are BOOST_xxx_SOURCE defined AND b. one of BOOST_ALL_DYN_LINK and BOOST_xxx_DYN_LINK is defined
2. __declspec(dllimport) if a. BOOST_HAS_DECLSPEC is defined b. BOOST_xxx_SOURCE is not defined c. one of BOOST_ALL_DYN_LINK and BOOST_xxx_DYN_LINK is defined
3. nothing, otherwise.
Paul Mensonides once sent me some code which does a much simple version of the above, but it included four headers from Boost.PP and was 29 lines long.
I don't think that should be an obstacle, if it gets the job done efficiently. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

"David Abrahams" <dave@boost-consulting.com> wrote in message news:uvfekn9qc.fsf@boost-consulting.com...
"Jonathan Turkanis" <technews@kangaroologic.com> writes:
What would be nice is a macro BOOST_DECLSPEC(xxx) which expands to
1. __declspec(dllexport) if
a. BOOST_HAS_DECLSPEC are BOOST_xxx_SOURCE defined AND b. one of BOOST_ALL_DYN_LINK and BOOST_xxx_DYN_LINK is defined
2. __declspec(dllimport) if a. BOOST_HAS_DECLSPEC is defined b. BOOST_xxx_SOURCE is not defined c. one of BOOST_ALL_DYN_LINK and BOOST_xxx_DYN_LINK is defined
3. nothing, otherwise.
Paul Mensonides once sent me some code which does a much simple version of
the
above, but it included four headers from Boost.PP and was 29 lines long.
I don't think that should be an obstacle, if it gets the job done efficiently.
I guess you're right. I was thinking it would go in <boost/config.hpp>, but really it could go in <boost/config/declspec.hpp>, for example. Jonathan

Jonathan Turkanis wrote:
1. __declspec(dllexport) if
a. BOOST_HAS_DECLSPEC are BOOST_xxx_SOURCE defined AND b. one of BOOST_ALL_DYN_LINK and BOOST_xxx_DYN_LINK is defined
I think handling BOOST_xxx_DYN_LINK is problematic. You would need one declspec macro for each library (I think this is what Dave meant). Stefan

In order to export class from dynamic library one needs to add something as:
__declspec(dllexport)
wrapped in a macro. (Win32 example.)
Right now libraries define their own macros, e.g Iostreams has BOOST_IO_DECL and Regex uses BOOST_REGEX_DECL. There could be more.
I suggest common macro, BOOST_DECL to be used Boost-wide.
Its value may be by default empty or deduced from BOOST_ALL_DYN_LINK as it is done in Regex.
But what happens when lib A calls lib B, so lib A needs to be exported and lib B needs to be imported? John.
participants (5)
-
David Abrahams
-
John Maddock
-
Jonathan Turkanis
-
Pavel Vozenilek
-
Stefan Slapeta