|
Boost Users : |
Subject: Re: [Boost-users] Boost-users Digest, Vol 2858, Issue 2
From: Alex Perry (Alex.Perry_at_[hidden])
Date: 2011-09-28 14:00:23
On Wed, 28 Sep 2011 15:54:59 Christopher Pisz wrote :-
> This might be more of a windows question, but...
>
> Everytime I use a boost template as part of a class interface that is exported
> from a dll, I get this compiler warning.
>
> warning
> C3251: 'boost_enable_shared_from_this<T>::weak_this_':class
> 'boost::weak_ptr<T> ' needs to have a dll-interface to be used by clients of
> class 'boost::enable_shared_from_this<T>'
>
> How do I solve these types of errors?
Sadly with great difficulty (at least that was my experience) - Generally its so painful that its just easier not to export template code across a dll boundary. As you say its more of a windows question rather than a boost one see http://www.codesynthesis.com/~boris/blog/2010/01/18/dll-export-cxx-templates/ or any other result from a google search of template dll export.
However if you are in full control of your project and can ensure consistent use of heap (/MD), exception handling and can always be 100% certain that all the dlls are compiled with the same version of the vs compiler you can just ignore the warnings (#pragma warning is always useful : - ) ) and things will sort of work - till they just don't at some point when someone breaks the rules above - so I wouldn't recommend it for production code.
Alex
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net