From 1f0f1c2dcf82bb37d34b75dfce3125dca2820824 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sun, 30 May 2010 17:31:09 +0000 Subject: [PATCH] Update link_test to check that separate file template instantiation and export works as expected. [SVN r62332] --- test/link/Jamfile.v2 | 3 +++ test/link/link_test.cpp | 38 +++++++++++++++++++++++++++++++++----- test/link/link_test.hpp | 37 ++++++++++++++++++++++++++++++++++--- test/link/main.cpp | 4 ++++ test/link/test/Jamfile.v2 | 6 ++++-- 5 files changed, 78 insertions(+), 10 deletions(-) diff --git a/test/link/Jamfile.v2 b/test/link/Jamfile.v2 index 9e676e8e..c5da6c29 100644 --- a/test/link/Jamfile.v2 +++ b/test/link/Jamfile.v2 @@ -14,3 +14,6 @@ lib link_test : link_test.cpp debug release ; +run main.cpp link_test : : : BOOST_DYN_LINK=1 BOOST_CONFIG_NO_LIB shared shared single : link_test_test ; + + diff --git a/test/link/link_test.cpp b/test/link/link_test.cpp index f0a66263..be80bfcd 100644 --- a/test/link/link_test.cpp +++ b/test/link/link_test.cpp @@ -9,6 +9,8 @@ #define BOOST_CONFIG_SOURCE #include "link_test.hpp" +#include +#include bool BOOST_CONFIG_DECL check_options( bool m_dyn_link, @@ -17,10 +19,36 @@ bool BOOST_CONFIG_DECL check_options( bool m_debug, bool m_stlp_debug) { - return (m_dyn_link == dyn_link) - && (m_dyn_rtl == dyn_rtl) - && (m_has_threads == has_threads) - && (m_debug == debug) - && (m_stlp_debug == stl_debug); + if(m_dyn_link != dyn_link) + { + std::cout << "Dynamic link options do not match" << std::endl; + std::cout << "Application setting = " << m_dyn_link << " Library setting = " << dyn_link << std::endl; + return false; + } + if(m_dyn_rtl != dyn_rtl) + { + std::cout << "Runtime library options do not match" << std::endl; + std::cout << "Application setting = " << m_dyn_rtl << " Library setting = " << dyn_rtl << std::endl; + return false; + } + if(m_has_threads != has_threads) + { + std::cout << "Threading options do not match" << std::endl; + std::cout << "Application setting = " << m_has_threads << " Library setting = " << has_threads << std::endl; + return false; + } + if(m_debug != debug) + { + std::cout << "Debug options do not match" << std::endl; + std::cout << "Application setting = " << m_debug << " Library setting = " << debug << std::endl; + return false; + } + if(m_stlp_debug != stl_debug) + { + std::cout << "STLPort debug options do not match" << std::endl; + std::cout << "Application setting = " << m_stlp_debug << " Library setting = " << stl_debug << std::endl; + return false; + } + return true; } diff --git a/test/link/link_test.hpp b/test/link/link_test.hpp index 16f91bf2..8d6333bb 100644 --- a/test/link/link_test.hpp +++ b/test/link/link_test.hpp @@ -44,11 +44,11 @@ static const bool stl_debug = false; // // set up import and export options: // -#if defined(BOOST_HAS_DECLSPEC) && defined(BOOST_DYN_LINK) +#if defined(BOOST_DYN_LINK) # ifdef BOOST_CONFIG_SOURCE -# define BOOST_CONFIG_DECL __declspec(dllexport) +# define BOOST_CONFIG_DECL BOOST_SYMBOL_EXPORT # else -# define BOOST_CONFIG_DECL __declspec(dllimport) +# define BOOST_CONFIG_DECL BOOST_SYMBOL_IMPORT # endif #endif #ifndef BOOST_CONFIG_DECL @@ -73,5 +73,36 @@ bool BOOST_CONFIG_DECL check_options( # include #endif +#ifndef BOOST_NO_EXTERN_TEMPLATE + +template +T test_free_proc(T v) +{ + return v; +} + +template +struct tester +{ + static int test(); +}; + +template +int tester::test() +{ + return 0; +} + +#ifdef BOOST_CONFIG_SOURCE +template BOOST_SYMBOL_EXPORT int test_free_proc(int); +template BOOST_SYMBOL_EXPORT int tester::test(); +#else +extern template BOOST_SYMBOL_IMPORT int test_free_proc(int); +extern template BOOST_SYMBOL_IMPORT int tester::test(); +#endif + +#endif // BOOST_NO_EXTERN_TEMPLATE + #endif // BOOST_LINK_TEST_HPP + diff --git a/test/link/main.cpp b/test/link/main.cpp index 06643eb5..3926684a 100644 --- a/test/link/main.cpp +++ b/test/link/main.cpp @@ -9,6 +9,10 @@ int main() { +#ifndef BOOST_NO_EXTERN_TEMPLATE + test_free_proc(0); + tester::test(); +#endif return check_options(dyn_link, dyn_rtl, has_threads, debug, stl_debug) ? 0 : -1; } diff --git a/test/link/test/Jamfile.v2 b/test/link/test/Jamfile.v2 index 234da7cc..22668af2 100644 --- a/test/link/test/Jamfile.v2 +++ b/test/link/test/Jamfile.v2 @@ -69,13 +69,14 @@ autolink-lib link_test : ../link_test.cpp : ; + explicit link_test ; run ../main.cpp link_test - : : : msvc-8.0:no static static single debug : link_test_ssd ; + : : : msvc-8.0:no msvc-9.0:no msvc-10.0:no static static single debug : link_test_ssd ; run ../main.cpp link_test - : : : msvc-8.0:no static static single release : link_test_ssr ; + : : : msvc-8.0:no msvc-9.0:no msvc-10.0:no static static single release : link_test_ssr ; run ../main.cpp link_test : : : static static multi debug : link_test_smd ; @@ -113,3 +114,4 @@ run ../main.cpp link_test +