[archive]: Problem with creating a C-Interface DLL using Serialization/Archive

I'm writing a DLL which uses Boost for the Serialization (version 1.36.0). Because it has to maintain in different system I want to maintain a pure C-Interface DLL. As soon as I use the Boost-Library by activating the two lines boost::archive::text_iarchive ia(is); ia >> foo; in the function CNwDeSerialize_Test( ) it's C++ Interface becomes exposed in my C-Interface. Anybody got an idea why and what I can do to prevent it ? Regards Martin //===================================================== // Modul: stdafx.h #include <boost/archive/tmpdir.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> #include <boost/serialization/base_object.hpp> #include <boost/serialization/utility.hpp> #include <boost/serialization/list.hpp> #include <boost/serialization/assume_abstract.hpp> #include <boost/shared_ptr.hpp> //===================================================== // Modul: ChannelNwManager.h // ChannelNwManager.h : Defines the exported functions for the DLL application. // #ifdef __cplusplus extern "C" { #endif #ifdef CHANNELNWMANAGER_EXPORTS #define CHNNWMANAGER_API extern "C" __declspec(dllexport) #else #define CHNNWMANAGER_API extern "C" __declspec(dllimport) #endif CHNNWMANAGER_API void CNwDeSerialize_Test( void ); #ifdef __cplusplus } #endif //===================================================== // Modul: ChannelNwManager.cpp #include "stdafx.h" extern "C" __declspec(dllexport) void CNwDeSerialize_Test( ) { int foo; std::istringstream is("1"); // boost::archive::text_iarchive ia(is); // ia >> foo; } // ===================================================== // Modul: ChannelNwManager.cpp #include "stdafx.h" extern "C" __declspec(dllexport) void CNwDeSerialize_Test( ) { int foo; std::istringstream is("1"); boost::archive::text_iarchive ia(is); ia >> foo; }

Likely due to the fact that you're importing the DLL version of the library. But is this a problem. The interface may be exposed, but no one has to call it. Alternatively, you might build the DLL so that it uses the static version of the library, but that might have other problematiic side effects. Robert Ramey "von Arx, Martin" <Martin.von-Arx@albistechnologies.com> wrote in message news:8A0D9960AA14A04D864377FD63F1FE401F7F0975E2@SBUA0011.albis.local... I'm writing a DLL which uses Boost for the Serialization (version 1.36.0). Because it has to maintain in different system I want to maintain a pure C-Interface DLL. As soon as I use the Boost-Library by activating the two lines boost::archive::text_iarchive ia(is); ia >> foo; in the function CNwDeSerialize_Test( ) it's C++ Interface becomes exposed in my C-Interface. Anybody got an idea why and what I can do to prevent it ? Regards Martin //===================================================== // Modul: stdafx.h #include <boost/archive/tmpdir.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> #include <boost/serialization/base_object.hpp> #include <boost/serialization/utility.hpp> #include <boost/serialization/list.hpp> #include <boost/serialization/assume_abstract.hpp> #include <boost/shared_ptr.hpp> //===================================================== // Modul: ChannelNwManager.h // ChannelNwManager.h : Defines the exported functions for the DLL application. // #ifdef __cplusplus extern "C" { #endif #ifdef CHANNELNWMANAGER_EXPORTS #define CHNNWMANAGER_API extern "C" __declspec(dllexport) #else #define CHNNWMANAGER_API extern "C" __declspec(dllimport) #endif CHNNWMANAGER_API void CNwDeSerialize_Test( void ); #ifdef __cplusplus } #endif //===================================================== // Modul: ChannelNwManager.cpp #include "stdafx.h" extern "C" __declspec(dllexport) void CNwDeSerialize_Test( ) { int foo; std::istringstream is("1"); // boost::archive::text_iarchive ia(is); // ia >> foo; } // ===================================================== // Modul: ChannelNwManager.cpp #include "stdafx.h" extern "C" __declspec(dllexport) void CNwDeSerialize_Test( ) { int foo; std::istringstream is("1"); boost::archive::text_iarchive ia(is); ia >> foo; } ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Robert Ramey
-
von Arx, Martin