
I've got a working patch set lying around. Please find it attached. Real life got in the way (as usual)...
Your patch has been VERY helpful, and I've used it as the starting point! Thanks!
FYI, there is an open ticket on this: https://svn.boost.org/trac/boost/ticket/2114 which still requires some work (mostly tests and updated docs) before rolling out.
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. If you don't decorate my_exception at all, VC++ is happy, but GCC shared libraries compiled with -fvisibility=hidden can't successfully throw exceptions up to callers outside the shared library. The only way around that I can see is to use a separate macro that is only defined for GCC.
Yeh, that's a tricky one, 'cos VC++ will warn almost whatever you do. I *think* the correct thing to do for header only classes is to mark them as __declspec(dllimport) - that way if you contain or inherit from them in an exported class you won't get more warnings - the main culprit here is noncopyable which is unusable without copious warnings from VC++. Oh and I think I've had warnings when containing a shared_ptr in an exported class too... in fact come to think of it if I write an exported class like this: class BOOST_SYMBOL_EXPORT foo { private: some_boost_type member; }; Won't I have issues unless "some_boost_type" is declared visible/exported? Bare in mind that this could be practically any template declared in Boost :-( Just thinking out loud yours, John.