Skip to content
Permalink
Browse files

Rename `BOOL` to `BOOLIFY` (#1107)

Prevents conflicts when this header is included in a project using Objective-C.
  • Loading branch information...
gwynne authored and Lukasa committed Aug 13, 2019
1 parent ab9b8eb commit 584e10792864448e0a6ff1a33b73e63c72d2be67
Showing with 7 additions and 7 deletions.
  1. +7 −7 Sources/CNIOAtomics/include/cpp_magic.h
@@ -189,7 +189,7 @@
* Macro version of C's famous "cast to bool" operator (i.e. !!) which takes
* anything and casts it to 0 if it is 0 and 1 otherwise.
*/
#define BOOL(x) NOT(NOT(x))
#define BOOLIFY(x) NOT(NOT(x))

/**
* Logical OR. Simply performs a lookup.
@@ -225,7 +225,7 @@
* 4. Note that the "true" clause is in the extra set of brackets; thus these
* become the arguments to _IF_0 or _IF_1 and thus a selection is made!
*/
#define IF(c) _IF(BOOL(c))
#define IF(c) _IF(BOOLIFY(c))
#define _IF(c) CAT(_IF_,c)
#define _IF_0(...)
#define _IF_1(...) __VA_ARGS__
@@ -240,7 +240,7 @@
*
* The mechanism is analogous to IF.
*/
#define IF_ELSE(c) _IF_ELSE(BOOL(c))
#define IF_ELSE(c) _IF_ELSE(BOOLIFY(c))
#define _IF_ELSE(c) CAT(_IF_ELSE_,c)
#define _IF_ELSE_0(t,f) f
#define _IF_ELSE_1(t,f) t
@@ -263,12 +263,12 @@
* 0 when it is expanded. In the latter, a non-zero result remains. If the
* first argument started with parentheses these will mostly not contain
* only a single 0, but e.g a C cast or some arithmetic operation that will
* cause the BOOL in _END_OF_ARGUMENTS_ to be one.
* 4. BOOL is used to force non-zero results into 1 giving the clean 0 or 1
* cause the BOOLIFY in _END_OF_ARGUMENTS_ to be one.
* 4. BOOLIFY is used to force non-zero results into 1 giving the clean 0 or 1
* output required.
*/
#define HAS_ARGS(...) BOOL(FIRST(_END_OF_ARGUMENTS_ __VA_ARGS__)(0))
#define _END_OF_ARGUMENTS_(...) BOOL(FIRST(__VA_ARGS__))
#define HAS_ARGS(...) BOOLIFY(FIRST(_END_OF_ARGUMENTS_ __VA_ARGS__)(0))
#define _END_OF_ARGUMENTS_(...) BOOLIFY(FIRST(__VA_ARGS__))


/**

0 comments on commit 584e107

Please sign in to comment.
You can’t perform that action at this time.