From 151a9e9f5256e4bca551d834cff8888b5aed936b Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Sat, 14 Aug 2021 12:03:34 -0700 Subject: [PATCH 1/2] Guard `__has_attribute` for compilers that don't support it Signed-off-by: Larry Gritz --- cmake/OpenEXRConfig.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/OpenEXRConfig.h.in b/cmake/OpenEXRConfig.h.in index a9b9bf5e5..e9a1c2c68 100644 --- a/cmake/OpenEXRConfig.h.in +++ b/cmake/OpenEXRConfig.h.in @@ -99,7 +99,7 @@ // for enums and templates, and isn't well documented, but causes // the vtable and typeinfo to be made visible, but not necessarily // all the members -# if __has_attribute(__type_visibility__) +# if defined(__has_attribute) && __has_attribute(__type_visibility__) # define OPENEXR_PUBLIC_TYPE_VISIBILITY_ATTRIBUTE __attribute__ ((__type_visibility__ ("default"))) # endif From e4fa4b4f4e8b5b7949fb5efbefa304067530eec6 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Mon, 16 Aug 2021 08:29:52 -0700 Subject: [PATCH 2/2] Revision Signed-off-by: Larry Gritz --- cmake/OpenEXRConfig.h.in | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmake/OpenEXRConfig.h.in b/cmake/OpenEXRConfig.h.in index e9a1c2c68..23a2426df 100644 --- a/cmake/OpenEXRConfig.h.in +++ b/cmake/OpenEXRConfig.h.in @@ -56,6 +56,14 @@ (uint32_t(OPENEXR_VERSION_MINOR) << 16) | \ (uint32_t(OPENEXR_VERSION_PATCH) << 8)) + +// On modern versions of gcc & clang, __has_attribute can test support for +// __attribute__((attr)). Make sure it's safe for other compilers. +#ifndef __has_attribute +# define __has_attribute(x) 0 +#endif + + // Whether the user configured the library to have symbol visibility // tagged #cmakedefine OPENEXR_ENABLE_API_VISIBILITY @@ -99,7 +107,7 @@ // for enums and templates, and isn't well documented, but causes // the vtable and typeinfo to be made visible, but not necessarily // all the members -# if defined(__has_attribute) && __has_attribute(__type_visibility__) +# if __has_attribute(__type_visibility__) # define OPENEXR_PUBLIC_TYPE_VISIBILITY_ATTRIBUTE __attribute__ ((__type_visibility__ ("default"))) # endif