Boost logo

Boost :

Subject: Re: [boost] [config] GCC symbol visibility across shared libraries
From: Beman Dawes (bdawes_at_[hidden])
Date: 2010-05-19 17:06:22


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.  I mark classes with __declspec(dllexport).  Is it that VC's linker notices that there are no symbols in the DLL for a header-only class and complains?

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'

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.

--Beman


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