From 157603b5971327133e99e52335a128ef6c9d23dc Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 23 Nov 2008 15:44:11 +0000 Subject: [PATCH] first pass at a link compatibility check --- include/libtorrent/session.hpp | 40 ++++++++++++++++++++++++++++++++++ src/session.cpp | 4 +++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index 0bda8eb87..fae835aa6 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -65,6 +65,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_id.hpp" #include "libtorrent/storage.hpp" +#include #ifdef _MSC_VER # include @@ -80,6 +81,45 @@ namespace libtorrent class natpmp; class upnp; + // this is used to create linker errors when trying to link to + // a library with a conflicting build configuration than the application +#ifdef NDEBUG +#define G _release +#else +#define G _debug +#endif + +#ifdef TORRENT_USE_OPENSSL +#define S _ssl +#else +#define S _nossl +#endif + +#ifdef TORRENT_DISABLE_DHT +#define D _nodht +#else +#define D _dht +#endif + +#ifdef TORRENT_DISABLE_POOL_ALLOCATOR +#define P _nopoolalloc +#else +#define P _poolalloc +#endif + +#define TORRENT_LINK_TEST_PREFIX libtorrent_build_config +#define TORRENT_LINK_TEST_NAME BOOST_PP_CAT(TORRENT_LINK_TEST_PREFIX, BOOST_PP_CAT(P, BOOST_PP_CAT(D, BOOST_PP_CAT(S, G)))) +#undef P +#undef D +#undef S +#undef G + + inline void test_link() + { + extern void TORRENT_LINK_TEST_NAME(); + TORRENT_LINK_TEST_NAME(); + } + namespace fs = boost::filesystem; namespace aux diff --git a/src/session.cpp b/src/session.cpp index 8876d4abc..8a5a87b8e 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -91,6 +91,8 @@ void stop_malloc_debug(); namespace libtorrent { + TORRENT_EXPORT void TORRENT_LINK_TEST_NAME() {} + std::string log_time() { static const ptime start = time_now(); @@ -123,7 +125,7 @@ namespace libtorrent ) : m_impl(new session_impl(listen_port_range, id, listen_interface #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING - , logpath + , logpath #endif )) {