From e1cc005f4c5a14069ac7492fbe107e44cdff30c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florin=20Cri=C8=99an?= Date: Fri, 28 May 2021 11:06:59 +0300 Subject: [PATCH 1/2] #3420 Properly declare all overloads of testing::internal::PrintTo as DLL exports This was causing the following linker error on Microsoft Visual C++ when compiling as a DLL: ``` googletest-printers-test.cc.obj : error LNK2019: unresolved external symbol "void __cdecl testing::internal::PrintTo(char16_t const *,class std::basic_ostream > *)" (?PrintTo@internal@testing@@YAXPEB_SPEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z) referenced in function "public: static void __cdecl testing::internal::UniversalPrinter::Print(char16_t const * const &,class std::basic_ostream > *)" (?Print@?$UniversalPrinter@PEB_S@internal@testing@@SAXAEBQEB_SPEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z) googletest-printers-test.cc.obj : error LNK2019: unresolved external symbol "void __cdecl testing::internal::PrintTo(char32_t const *,class std::basic_ostream > *)" (?PrintTo@internal@testing@@YAXPEB_UPEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z) referenced in function "public: static void __cdecl testing::internal::UniversalPrinter::Print(char32_t const * const &,class std::basic_ostream > *)" (?Print@?$UniversalPrinter@PEB_U@internal@testing@@SAXAEBQEB_UPEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z) ``` --- googletest/include/gtest/gtest-printers.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index 978420e8..076c9de1 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -501,18 +501,18 @@ inline void PrintTo(unsigned char* s, ::std::ostream* os) { } #ifdef __cpp_char8_t // Overloads for u8 strings. -void PrintTo(const char8_t* s, ::std::ostream* os); +GTEST_API_ void PrintTo(const char8_t* s, ::std::ostream* os); inline void PrintTo(char8_t* s, ::std::ostream* os) { PrintTo(ImplicitCast_(s), os); } #endif // Overloads for u16 strings. -void PrintTo(const char16_t* s, ::std::ostream* os); +GTEST_API_ void PrintTo(const char16_t* s, ::std::ostream* os); inline void PrintTo(char16_t* s, ::std::ostream* os) { PrintTo(ImplicitCast_(s), os); } // Overloads for u32 strings. -void PrintTo(const char32_t* s, ::std::ostream* os); +GTEST_API_ void PrintTo(const char32_t* s, ::std::ostream* os); inline void PrintTo(char32_t* s, ::std::ostream* os) { PrintTo(ImplicitCast_(s), os); } From 26a1569c72e85a77096cae6fbe95228a4ca765d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florin=20Cri=C8=99an?= Date: Fri, 28 May 2021 12:05:04 +0300 Subject: [PATCH 2/2] #3420 Declare MarkAsIgnored as a DLL export This was causing the following linker error on Microsoft Visual C++ when compiling as a DLL: ``` googletest-param-test-test.cc.obj : error LNK2019: unresolved external symbol "public: __cdecl testing::internal::MarkAsIgnored::MarkAsIgnored(char const *)" (??0MarkAsIgnored@internal@testing@@QEAA@PEBD@Z) referenced in function "void __cdecl works_here::`dynamic initializer for 'gtest_allow_ignore_NotInstantiatedTest''(void)" (??__Egtest_allow_ignore_NotInstantiatedTest@works_here@@YAXXZ) ``` --- googletest/include/gtest/internal/gtest-param-util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h index 3e49a6ba..4af22ca7 100644 --- a/googletest/include/gtest/internal/gtest-param-util.h +++ b/googletest/include/gtest/internal/gtest-param-util.h @@ -478,7 +478,7 @@ class ParameterizedTestSuiteInfoBase { // // Report a the name of a test_suit as safe to ignore // as the side effect of construction of this type. -struct MarkAsIgnored { +struct GTEST_API_ MarkAsIgnored { explicit MarkAsIgnored(const char* test_suite); };