From e293f93f20392be287d85dc70d39362c2489019f Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Thu, 31 Oct 2024 10:57:43 +0100 Subject: [PATCH 1/3] config.hh: Use c++11 attribute when C++11 is activated --- config.hh.cmake | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/config.hh.cmake b/config.hh.cmake index d3b4a367b..5a5f3c18a 100644 --- a/config.hh.cmake +++ b/config.hh.cmake @@ -50,13 +50,23 @@ # else // On Linux, for GCC >= 4, tag symbols using GCC extension. # if __GNUC__ >= 4 -# define @LIBRARY_NAME@_DLLIMPORT __attribute__ ((visibility("default"))) -# define @LIBRARY_NAME@_DLLEXPORT __attribute__ ((visibility("default"))) -# define @LIBRARY_NAME@_DLLLOCAL __attribute__ ((visibility("hidden"))) -# define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DECLARATION_DLLIMPORT __attribute__ ((visibility("default"))) -# define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DECLARATION_DLLEXPORT __attribute__ ((visibility("default"))) -# define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DEFINITION_DLLIMPORT -# define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DEFINITION_DLLEXPORT +# if defined(__cplusplus) && (__cplusplus >= 201103L) +# define @LIBRARY_NAME@_DLLIMPORT [[gnu::visibility("default")]] +# define @LIBRARY_NAME@_DLLEXPORT [[gnu::visibility("default")]] +# define @LIBRARY_NAME@_DLLLOCAL [[gnu::visibility("hidden")]] +# define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DECLARATION_DLLIMPORT [[gnu::visibility("default")]] +# define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DECLARATION_DLLEXPORT [[gnu::visibility("default")]] +# define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DEFINITION_DLLIMPORT +# define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DEFINITION_DLLEXPORT +# else +# define @LIBRARY_NAME@_DLLIMPORT __attribute__ ((visibility("default"))) +# define @LIBRARY_NAME@_DLLEXPORT __attribute__ ((visibility("default"))) +# define @LIBRARY_NAME@_DLLLOCAL __attribute__ ((visibility("hidden"))) +# define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DECLARATION_DLLIMPORT __attribute__ ((visibility("default"))) +# define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DECLARATION_DLLEXPORT __attribute__ ((visibility("default"))) +# define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DEFINITION_DLLIMPORT +# define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DEFINITION_DLLEXPORT +# endif # else // Otherwise (GCC < 4 or another compiler is used), export everything. # define @LIBRARY_NAME@_DLLIMPORT From ab9290e1ba4472341c781e03c7b6dfbc09fc9a44 Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Thu, 31 Oct 2024 11:13:18 +0100 Subject: [PATCH 2/3] config.hh: Add some comments --- config.hh.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.hh.cmake b/config.hh.cmake index 5a5f3c18a..3d64b9f8b 100644 --- a/config.hh.cmake +++ b/config.hh.cmake @@ -50,6 +50,8 @@ # else // On Linux, for GCC >= 4, tag symbols using GCC extension. # if __GNUC__ >= 4 +// Use C++11 attribute if avaiable. +// This avoid issue when mixing old and C++11 attributes with GCC < 13 # if defined(__cplusplus) && (__cplusplus >= 201103L) # define @LIBRARY_NAME@_DLLIMPORT [[gnu::visibility("default")]] # define @LIBRARY_NAME@_DLLEXPORT [[gnu::visibility("default")]] From cade6478255c013a35994f4804af853bfd9bd370 Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Thu, 31 Oct 2024 15:20:04 +0100 Subject: [PATCH 3/3] config.hh: Don't use c++11 attributes in explicit template instantiation --- config.hh.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config.hh.cmake b/config.hh.cmake index 3d64b9f8b..f3b0658a1 100644 --- a/config.hh.cmake +++ b/config.hh.cmake @@ -56,8 +56,9 @@ # define @LIBRARY_NAME@_DLLIMPORT [[gnu::visibility("default")]] # define @LIBRARY_NAME@_DLLEXPORT [[gnu::visibility("default")]] # define @LIBRARY_NAME@_DLLLOCAL [[gnu::visibility("hidden")]] -# define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DECLARATION_DLLIMPORT [[gnu::visibility("default")]] -# define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DECLARATION_DLLEXPORT [[gnu::visibility("default")]] +// gnu::visibility is not working with clang and explicit template instantiation +# define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DECLARATION_DLLIMPORT __attribute__ ((visibility("default"))) +# define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DECLARATION_DLLEXPORT __attribute__ ((visibility("default"))) # define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DEFINITION_DLLIMPORT # define @LIBRARY_NAME@_EXPLICIT_INSTANTIATION_DEFINITION_DLLEXPORT # else