Skip to content

Commit

Permalink
Separate __has_attribute test from actual usage, as per GCC
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rmottola committed Jan 20, 2025
1 parent 2f21360 commit 943f8d8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Headers/CoreFoundation/CFCGTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

2 comments on commit 943f8d8

@rmottola
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rfm sorry accidentally pushed to master, I created a branch but forgot to switch it.
I thought that reverting last commit and forcing a push was dirtier. In case this commit is an issue or causes issue, feel free to revert it by reverse apply. It really shouldn't though!

@rfm
Copy link
Contributor

@rfm rfm commented on 943f8d8 Jan 21, 2025 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.