Separate __has_attribute test from actual usage, as per GCC

documentaiton.

The first `#if' test succeeds only when the operator is supported by the version of GCC (or another compiler) being used. Only when that test succeeds is it valid to use __has_attribute as a preprocessor operator. As a result, combining the two tests into a single expression as shown below would only be valid with a compiler that supports the operator but not with others that don't.

https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html
This commit is contained in:
Riccardo Mottola 2025-01-20 12:47:41 +01:00
parent 2f21360642
commit 943f8d82c3

View file

@ -29,8 +29,12 @@
#define CF_DEFINES_CG_TYPES
#if defined(__has_attribute) && __has_attribute(objc_boxable)
# define CF_BOXABLE __attribute__((objc_boxable))
#if defined __has_attribute
# if __has_attribute(objc_boxable)
# define CF_BOXABLE __attribute__((objc_boxable))
# else
# define CF_BOXABLE
# endif
#else
# define CF_BOXABLE
#endif