Boost logo

Boost :

Subject: Re: [boost] [config] GCC symbol visibility across shared libraries
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2010-05-20 15:02:28


Jürgen Hunold wrote:
> Rob Stewart wrote:
>
> > #define BOOST_SYMBOL_EXPORT
> > #define BOOST_SYMBOL_IMPORT
> > #define BOOST_SYMBOL_VISIBLE
> >
> > #ifdef BOOST_HAS_DECLSPEC
> > # undef BOOST_SYMBOL_EXPORT
> > # define BOOST_SYMBOL_EXPORT __declspec(dllexport)
> > # undef BOOST_SYMBOL_IMPORT
> > # define BOOST_SYMBOL_IMPORT __declspec(dllimport)
> > #elif defined BOOST_HAS_VISIBILITY
> > # undef BOOST_SYMBOL_VISIBLE
> > # define BOOST_SYMBOL_VISIBLE __attribute__(visibility("default"))
> > # ifdef BOOST_DEFAULT_VISIBILITY_IS_HIDDEN
> > # undef BOOST_SYMBOL_EXPORT
> > # define BOOST_SYMBOL_EXPORT BOOST_SYMBOL_VISIBLE
> > # endif
> > #endif
> >
> > BOOST_HAS_VISIBILITY would be undefined for most compilers,
> > but would be
> > defined for GCC (when __GNUC__ is defined, perhaps after
> > some particular
> > release, but I don't know when it was introduced).
>
> I had the same idea, but decided to take small steps.
> First, get visibility in with a minimal diff, then add
> support to Boost.Build
> and then refactor. It is __GNUC_ > 4, by the way ;-))

That's correct for BOOST_DEFAULT_VISIBILITY_IS_HIDDEN (for -fvisibility and the pragma), but the attribute was available before that.

> > BOOST_DEFAULT_VISIBILITY_IS_HIDDEN must be defined for GCC,
> > when __GNUC__
> > >= 4, but only if using -fvisiblity=hidden. I haven't
> > found a way to
> > detect that, so I guess it has to be assumed or defined via
> > the command line.
>
> No. Visibility can always be explicitly specified. So no
> BOOST_DEFAULT_VISIBILITY_IS_HIDDEN macro is needed.
> I would simply always #define BOOST_SYMBOL_EXPORT/IMPORT to
> the correct values.

Excellent point.

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


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