|
Boost : |
Subject: Re: [boost] [config] GCC symbol visibility across shared libraries
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2010-05-20 07:23:46
Beman Dawes wrote:
> On Wed, May 19, 2010 at 9:55 AM, Stewart, Robert
> <Robert.Stewart_at_[hidden]> wrote:
> > Beman Dawes wrote:
> >> On Thu, May 6, 2010 at 12:42 PM, Jürgen Hunold
> >> <juergen.hunold_at_[hidden]> wrote:
> >>
> >> > The patch introduces two Boost.Config macros
> >> > - BOOST_SYMBOL_EXPORT
> >> > - BOOST_SYMBOL_IMPORT
> >>
> >> AFAICT, a third macro is needed for GCC. I've named it
> >> BOOST_SYMBOL_VISIBLE and define it as
> >> __attribute__((visibility("default")))
> >>
> >> The need for this macro arises in header only classes like this:
> >>
> >> class BOOST_SYMBOL_VISIBLE my_exception
> >> : public std::runtime_error { ... };
> >>
> >> If you use BOOST_SYMBOL_EXPORT, VC++ will warn because
> >> __declspec(dllexport) isn't valid in this context.
> >
> > I don't understand the problem in that case.
>
> At the least, you this warning:
>
> c:\boost\trunk\boost\system\system_error.hpp(26) : warning C4275: non
> dll-interface class 'std::runtime_error' used as base for
> dll-interface class 'boost::system::system_error'
I hate that warning!
> But for one of the Boost.System tests, VC++ gets so confused that it
> fails to inline the functions defined in the class, and you get a
> bunch of unresolved externals.
Wow!
Let me get this straight, then. Since the class is header only, it needn't be exported from a DLL, hence using dllexport is wrongheaded for MSVC. However, GCC's -fvisibility=hidden interferes because of the need to explicitly mark exception types as visible. Have I got things right so far?
Is there any other case in which a symbol must be marked visible explicitly where BOOST_SYMBOL_EXPORT is not appropriate? If not, BOOST_SYMBOL_VISIBLE is the wrong name. It should be BOOST_VISIBLE_EXCEPTION_TYPE or something like that to be clear that it is for use with exception types only.
_____
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