Clang keeps complain it ignores __declspec(dllexport) of basic_data<void> template instantitation definition in format.cc - #2220
Conversation
Clang keeps complain it ignores __declspec(dllexport) in format.cc's instantiation of "detail::basic_data<void>;"
```
C:/Users/User/AppData/Roaming/fmt-master/src/format.cc:58:17: warning: 'dllexport' attribute ignored on explicit instantiation definition [-Wignored-attributes]
template struct FMT_INSTANTIATION_DEF_API detail::basic_data<void>;
^
C:/Users/User/AppData/Roaming/fmt-master/include\fmt/core.h:228:37: note: expanded from macro 'FMT_INSTANTIATION_DEF_API'
# define FMT_INSTANTIATION_DEF_API FMT_API
^
C:/Users/User/AppData/Roaming/fmt-master/include\fmt/core.h:210:32: note: expanded from macro 'FMT_API'
# define FMT_API __declspec(dllexport)
^
1 warning generated.
```
I guess we have to make an explicit instantiation definition of `basic_data<void>` in format.cc (without `__declspec(dllexport)` )
and make an explicit instantiation declaration (aka `extern template`) in format.h instead
Add the template instantiation **declaration** of `basic_data<void>` the the template instantiation **definition** is in `format.cc`
|
Or should I move |
vitaut
left a comment
There was a problem hiding this comment.
Could you post the full warning message that you get? Also there are some CI failures.
Try remove FMT_INSTANTIATION_DEF_API from extern template
Fix removing the entire declaration because at line 999 there is one. CI Error in macOS.
By the way, this still does not succeed. It fails on However it's perhaps a clang 12 or mingw64 bug. |
|
|
||
| #if !defined(FMT_HEADER_ONLY) && defined(_WIN32) | ||
| # define FMT_CLASS_API FMT_MSC_WARNING(suppress : 4275) | ||
| # define FMT_INSTANTIATION_DEF_API |
There was a problem hiding this comment.
We cannot just remove __declspec(dllexport) because it will break a shared library. Instead it should be applied to a declaration that can be added to format.cc.
|
It seems there might has been some changes. [MinGW] Fix dllexport of explicit template instantiation To fix
|
FMT_INSTANTIATION_DEF_API follows FMT_API
D61118 : make dllexport on extern template, not the instantiation definition in format.cc [MinGW] Fix dllexport of explicit template instantiation https://reviews.llvm.org/D61118
Move FMT_INSTANTIATION_DEF_API to the declaration in format.h [MinGW] Fix dllexport of explicit template instantiation https://reviews.llvm.org/D61118
|
More over, FMT_INSTANTIATION_DEF_API shall be considered to be renamed. |
Sure |
| } // namespace detail | ||
|
|
||
| template struct FMT_INSTANTIATION_DEF_API detail::basic_data<void>; | ||
| template struct detail::basic_data<void>; |
There was a problem hiding this comment.
Please add a short comment saying that clang doesn't allow __declspec(dllexport) here.
Rename FMT_INSTANTIATION_DEF_API to FMT_INSTANTIATION_DECL_API [MinGW] Fix dllexport of explicit template instantiation https://reviews.llvm.org/D61118
Rename FMT_INSTANTIATION_DEF_API to FMT_INSTANTIATION_DECL_API [MinGW] Fix dllexport of explicit template instantiation https://reviews.llvm.org/D61118
Add a comment that clang now doesn't allow dllexport on template instantiation definitions. Mark them on tempalte instantiation declarations instead (in format.h). [MinGW] Fix dllexport of explicit template instantiation https://reviews.llvm.org/D61118
|
A comment is added but please feel free to edit it. |
vitaut
left a comment
There was a problem hiding this comment.
LGTM, just one remaining nit.
| } // namespace detail | ||
|
|
||
| template struct FMT_INSTANTIATION_DEF_API detail::basic_data<void>; | ||
| // Clang doesn't allow dllexport on template instantiation definitions (LLVM D61118) |
There was a problem hiding this comment.
nit: Please add . at the end of the sentence and apply clang-format.
|
Thanks |
Remove
__declspec(dllexport)from the definitionand add template instantiation declaration (aka
extern) informat.hI'm not sure the added position is correct, please check if it's okey.