-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support defining C99 bool as the BOOL type
Whether to use C99 bool can be set at build time using -DOBJC_BOOL_IS_BOOL_MODE=auto/always/never. Default is to use C99 bool if __OBJC_BOOL_IS_BOOL is defined and set to 1, which is currently the case for Clang on newer Apple platforms. This matches the behavior of Apple's libobjc (especially when combined with STRICT_APPLE_COMPATIBILITY). (See https://www.jviotti.com/2024/01/05/is-objective-c-bool-a-boolean-type-it-depends.html for more information about the __OBJC_BOOL_IS_BOOL definition.)
- Loading branch information
Showing
3 changed files
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,18 @@ | ||
#cmakedefine STRICT_APPLE_COMPATIBILITY @STRICT_APPLE_COMPATIBILITY@ | ||
|
||
#define OBJC_BOOL_IS_BOOL_MODE_AUTO 1 | ||
#define OBJC_BOOL_IS_BOOL_MODE_ALWAYS 2 | ||
#define OBJC_BOOL_IS_BOOL_MODE_NEVER 3 | ||
#cmakedefine OBJC_BOOL_IS_BOOL_MODE @OBJC_BOOL_IS_BOOL_MODE_CONFIG@ | ||
|
||
#define OBJC_BOOL_TYPE_STDBOOL 1 | ||
#define OBJC_BOOL_TYPE_TRADITIONAL 2 | ||
#define OBJC_BOOL_TYPE_APPLE 3 | ||
|
||
#if OBJC_BOOL_IS_BOOL_MODE == OBJC_BOOL_IS_BOOL_MODE_ALWAYS || (defined(__OBJC_BOOL_IS_BOOL) && OBJC_BOOL_IS_BOOL_MODE == OBJC_BOOL_IS_BOOL_MODE_AUTO) | ||
#define OBJC_BOOL_TYPE OBJC_BOOL_TYPE_STDBOOL | ||
#elif STRICT_APPLE_COMPATIBILITY | ||
#define OBJC_BOOL_TYPE OBJC_BOOL_TYPE_APPLE | ||
#else | ||
#define OBJC_BOOL_TYPE OBJC_BOOL_TYPE_TRADITIONAL | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters