Opened 5 years ago
Last modified 4 years ago
#13286 new Bugs
warning C4141: 'dllexport': used more than once
Reported by: | Owned by: | Robert Ramey | |
---|---|---|---|
Milestone: | To Be Determined | Component: | serialization |
Version: | Boost 1.65.0 | Severity: | Problem |
Keywords: | Cc: |
Description
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):
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
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.
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<> class BOOST_SYMBOL_VISIBLE codecvt_null<wchar_t> : public std::codecvt<wchar_t, char, std::mbstate_t> { - virtual BOOST_WARCHIVE_DECL BOOST_DLLEXPORT std::codecvt_base::result + virtual BOOST_WARCHIVE_DECL std::codecvt_base::result do_out( std::mbstate_t & state, const wchar_t * first1, @@ -75,7 +75,7 @@ class BOOST_SYMBOL_VISIBLE codecvt_null<wchar_t> : public std::codecvt<wchar_t, char * last2, char * & 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 & 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 & get_lock() BOOST_USED; + BOOST_SERIALIZATION_DECL static bool & get_lock() BOOST_USED; public: BOOST_DLLEXPORT static void lock(){ get_lock() = true;
Attachments (1)
Change History (2)
by , 4 years ago
Attachment: | 0001-Eliminate-dllexport-compile-and-link-warnings-per-ht.patch added |
---|
comment:1 by , 4 years ago
Note:
See TracTickets
for help on using tickets.
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.)
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.
Also we removed them from lines 21 & 49 of codecvt_null.cpp to eliminate two more warnings that occur while compiling Boost itself.