Skip to content

Commit 5969161

Browse files
committed
update
mention static data member clarify that relates explicit instantiation declaration wrong use of dllimport in example description
1 parent 4209e6c commit 5969161

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

libcxx/include/__config

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,8 @@ typedef __char32_t char32_t;
532532

533533
// _LIBCPP_HIDE_FROM_ABI is required for member functions defined within an inner class of a class template
534534
// (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).
537537
//
538538
// Previous versions of Clang did not exhibit this issue, but upcoming versions are expected to align with
539539
// GCC's behavior for compatibility. This is particularly important because some of libstdc++ packages
@@ -547,16 +547,18 @@ typedef __char32_t char32_t;
547547
// Therefore, a dedicated macro _LIBCPP_HIDE_FROM_ABI_MINGW_OR_AFTER_V1 is introduced. This macro expands to
548548
// _LIBCPP_HIDE_FROM_ABI only when targeting MinGW, and to _LIBCPP_HIDE_FROM_ABI_AFTER_V1 on all other platforms.
549549
//
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.
553554
//
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:
555556
//
556557
// - When exporting: 'extern template __declspec(dllexport) class TheTemplateClass<T>;'
557558
// 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.
558560
//
559-
// - When importing: 'extern template __declspec(dllimport) class TheTemplateClass<T>;'
561+
// - When importing: 'extern template class TheTemplateClass<T>;'
560562
// causes MinGW-GCC to also try importing nested types such as TheTemplateClass<T>::InnerClass,
561563
// even if they were never exported. This leads to linker errors like:
562564
// 'undefined reference to TheTemplateClass<T>::InnerClass::...'

0 commit comments

Comments
 (0)