Boost C++ Libraries: Ticket #13286: warning C4141: 'dllexport': used more than once https://svn.boost.org/trac10/ticket/13286 <p> The following warnings are emitted by Visual Studio 2017 when using boost/serialization as a shared library (and defining BOOST_ALL_DYN_LINK when using the library): </p> <pre class="wiki">C:\...\boost\include\boost-1_65_1\boost/archive/codecvt_null.hpp(68): warning C4141: 'dllexport': used more than once C:\...\boost\include\boost-1_65_1\boost/archive/codecvt_null.hpp(78): warning C4141: 'dllexport': used more than once C:\...\boost\include\boost-1_65_1\boost/serialization/singleton.hpp(94): warning C4141: 'dllexport': used more than once </pre><p> The problem is use of BOOST_*_DECL and BOOST_DLLEXPORT at the same time. Removing the BOOST_DLLEXPORT macro from those lines as done in the following patch fixes the problem. </p> <pre class="wiki">diff --git a/boost/include/boost-1_65_1/boost/archive/codecvt_null.hpp b/boost/include/boost-1_65_1/boost/archive/codecvt_null.hpp index 7bce2b9b..332ae9f9 100644 --- a/boost/include/boost-1_65_1/boost/archive/codecvt_null.hpp +++ b/boost/include/boost-1_65_1/boost/archive/codecvt_null.hpp @@ -65,7 +65,7 @@ public: template&lt;&gt; class BOOST_SYMBOL_VISIBLE codecvt_null&lt;wchar_t&gt; : public std::codecvt&lt;wchar_t, char, std::mbstate_t&gt; { - virtual BOOST_WARCHIVE_DECL BOOST_DLLEXPORT std::codecvt_base::result + virtual BOOST_WARCHIVE_DECL std::codecvt_base::result do_out( std::mbstate_t &amp; state, const wchar_t * first1, @@ -75,7 +75,7 @@ class BOOST_SYMBOL_VISIBLE codecvt_null&lt;wchar_t&gt; : public std::codecvt&lt;wchar_t, char * last2, char * &amp; next2 ) const BOOST_USED; - virtual BOOST_WARCHIVE_DECL BOOST_DLLEXPORT std::codecvt_base::result + virtual BOOST_WARCHIVE_DECL std::codecvt_base::result do_in( std::mbstate_t &amp; state, const char * first1, diff --git a/boost/include/boost-1_65_1/boost/serialization/singleton.hpp b/boost/include/boost-1_65_1/boost/serialization/singleton.hpp index b50afedb..b9e470fa 100644 --- a/boost/include/boost-1_65_1/boost/serialization/singleton.hpp +++ b/boost/include/boost-1_65_1/boost/serialization/singleton.hpp @@ -91,7 +91,7 @@ class BOOST_SYMBOL_VISIBLE singleton_module : public boost::noncopyable { private: - BOOST_SERIALIZATION_DECL BOOST_DLLEXPORT static bool &amp; get_lock() BOOST_USED; + BOOST_SERIALIZATION_DECL static bool &amp; get_lock() BOOST_USED; public: BOOST_DLLEXPORT static void lock(){ get_lock() = true; </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13286 Trac 1.4.3 Conrad Poelman <cpboost@…> Mon, 30 Apr 2018 20:34:45 GMT attachment set https://svn.boost.org/trac10/ticket/13286 https://svn.boost.org/trac10/ticket/13286 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">0001-Eliminate-dllexport-compile-and-link-warnings-per-ht.patch</span> </li> </ul> Ticket Conrad Poelman <cpboost@…> Mon, 30 Apr 2018 20:39:47 GMT <link>https://svn.boost.org/trac10/ticket/13286#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13286#comment:1</guid> <description> <p> We have seen the same problem. We applied the changes to remove BOOST_DLLEXPORT from the three places and it eliminated the compile warnings, but left us with link warnings about importing exported symbols. (Sorry, I had saved the full text of the warnings but Trac tossed away all my text when I went to add an attachment.) </p> <p> Instead we found if we removed BOOST_SERIALIZATION_DECL / BOOST_WARCHIVE_DECL from the same lines, and left in BOOST_DLLEXPORT, both compile and link warnings went away. </p> <p> Also we removed them from lines 21 &amp; 49 of codecvt_null.cpp to eliminate two more warnings that occur while compiling Boost itself. </p> </description> <category>Ticket</category> </item> </channel> </rss>