sys/util: fix macro support when building with C++

true and false in a C environment are macros that are defined to 1 and
0 respectively.  In C++ they are keywords, and as such cause failures
when macro tests require they expand to a 1 or 0 token.  Use the
actual token values rather than the macro names when defining the
macros.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2020-08-11 16:01:38 -05:00 committed by Maureen Helm
commit 235a5c1771
2 changed files with 2 additions and 2 deletions

View file

@ -493,7 +493,7 @@ uint8_t u8_to_dec(char *buf, uint8_t buflen, uint8_t value);
* *
* @param a macro to check for emptiness * @param a macro to check for emptiness
*/ */
#define IS_EMPTY(a) Z_IS_EMPTY_(a, true, false,) #define IS_EMPTY(a) Z_IS_EMPTY_(a, 1, 0,)
/** /**
* @brief Remove empty arguments from list. * @brief Remove empty arguments from list.

View file

@ -40,7 +40,7 @@
* ENABLED: Z_IS_ENABLED3(_YYYY, 1, 0) * ENABLED: Z_IS_ENABLED3(_YYYY, 1, 0)
* DISABLED Z_IS_ENABLED3(_XXXX 1, 0) * DISABLED Z_IS_ENABLED3(_XXXX 1, 0)
*/ */
#define Z_IS_ENABLED2(one_or_two_args) Z_IS_ENABLED3(one_or_two_args true, false) #define Z_IS_ENABLED2(one_or_two_args) Z_IS_ENABLED3(one_or_two_args 1, 0)
/* And our second argument is thus now cooked to be 1 in the case /* And our second argument is thus now cooked to be 1 in the case
* where the value is defined to 1, and 0 if not: * where the value is defined to 1, and 0 if not: