diff options
author | Tom Hughes <tomhughes@chromium.org> | 2021-04-30 15:31:16 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-05-03 21:40:21 +0000 |
commit | 6affaa1b390bf653fa8861d04c2d834a230c7487 (patch) | |
tree | 42e764b2565efac61d9ae98ec6ec4612b8eb1173 /include/compile_time_macros.h | |
parent | 2ddae23ef3a6a51db07675f3a495a961e3a74d5f (diff) | |
download | chrome-ec-6affaa1b390bf653fa8861d04c2d834a230c7487.tar.gz |
compile_time_macros: Make _IS_ARRAY work with C++
BRANCH=none
BUG=b:144959033
TEST=make buildall
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I199f05eabad1182ca2da4489361426d04da06691
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2864513
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'include/compile_time_macros.h')
-rw-r--r-- | include/compile_time_macros.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/compile_time_macros.h b/include/compile_time_macros.h index 510a71461e..8c5647b9c4 100644 --- a/include/compile_time_macros.h +++ b/include/compile_time_macros.h @@ -8,6 +8,10 @@ #ifndef __CROS_EC_COMPILE_TIME_MACROS_H #define __CROS_EC_COMPILE_TIME_MACROS_H +#ifdef __cplusplus +#include <type_traits> +#endif + /* sys/util.h in zephyr provides equivalents to most of these macros */ #ifdef CONFIG_ZEPHYR #include <sys/util.h> @@ -36,8 +40,12 @@ #define BUILD_CHECK_INLINE(value, cond_true) ((value) / (!!(cond_true))) /* Check that the value is an array (not a pointer) */ +#ifdef __cplusplus +#define _IS_ARRAY(arr) (std::is_array<decltype(arr)>::value) +#else #define _IS_ARRAY(arr) \ !__builtin_types_compatible_p(typeof(arr), typeof(&(arr)[0])) +#endif /** * ARRAY_SIZE - Number of elements in an array. |