From 943f8d82c3678c4711f0634a4804a4fdbbddaef9 Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Mon, 20 Jan 2025 12:47:41 +0100 Subject: [PATCH] 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 --- Headers/CoreFoundation/CFCGTypes.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Headers/CoreFoundation/CFCGTypes.h b/Headers/CoreFoundation/CFCGTypes.h index 13cef938a5..959edc99fb 100644 --- a/Headers/CoreFoundation/CFCGTypes.h +++ b/Headers/CoreFoundation/CFCGTypes.h @@ -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