@@ -532,8 +532,8 @@ typedef __char32_t char32_t;
532
532
533
533
// _LIBCPP_HIDE_FROM_ABI is required for member functions defined within an inner class of a class template
534
534
// (e.g., std::basic_ostream<...>::sentry::sentry(...)), due to inconsistent behavior in MinGW-GCC (and
535
- // Cygwin as well, in all relevant cases) regarding template instantiation and symbol visibility when combined
536
- // with __declspec(dllexport/dllimport ).
535
+ // Cygwin as well, in all relevant cases) regarding explicit instantiation declaration and symbol visibility
536
+ // when combined with __declspec(dllexport).
537
537
//
538
538
// Previous versions of Clang did not exhibit this issue, but upcoming versions are expected to align with
539
539
// GCC's behavior for compatibility. This is particularly important because some of libstdc++ packages
@@ -547,16 +547,18 @@ typedef __char32_t char32_t;
547
547
// Therefore, a dedicated macro _LIBCPP_HIDE_FROM_ABI_MINGW_OR_AFTER_V1 is introduced. This macro expands to
548
548
// _LIBCPP_HIDE_FROM_ABI only when targeting MinGW, and to _LIBCPP_HIDE_FROM_ABI_AFTER_V1 on all other platforms.
549
549
//
550
- // Going forward, whenever a new (static or non-static) member function is added to an inner class within a
551
- // class template, it must be annotated with _LIBCPP_HIDE_FROM_ABI to ensure proper symbol visibility when
552
- // targeting MinGW. Otherwise, the resulting DLL will be unusable due to missing symbols.
550
+ // Going forward, whenever a new (static or non-static) member function or static data member is added to an
551
+ // inner class within a class template that has explicit instantiation declaration, it must be annotated with
552
+ // _LIBCPP_HIDE_FROM_ABI to ensure proper symbol visibility when targeting MinGW. Otherwise, the resulting DLL
553
+ // will be unusable due to missing symbols.
553
554
//
554
- // The underlying issue arises from how MinGW-GCC handles template instantiation:
555
+ // The underlying issue arises from how MinGW-GCC handles explicit instantiation declaration of a class template :
555
556
//
556
557
// - When exporting: 'extern template __declspec(dllexport) class TheTemplateClass<T>;'
557
558
// allows exporting the outer template instantiation, but not its nested types (e.g., InnerClass).
559
+ // note: this is just a declaration, needs a definition as `template class TheTemplateClass<T>;' at somewere.
558
560
//
559
- // - When importing: 'extern template __declspec(dllimport) class TheTemplateClass<T>;'
561
+ // - When importing: 'extern template class TheTemplateClass<T>;'
560
562
// causes MinGW-GCC to also try importing nested types such as TheTemplateClass<T>::InnerClass,
561
563
// even if they were never exported. This leads to linker errors like:
562
564
// 'undefined reference to TheTemplateClass<T>::InnerClass::...'
0 commit comments