include: util.h: add extern "C"

extern "C" is missing.
This commit adds conditional extern "C" for cpp to
the beginning of the file and brackets the cpp template with
extern "C++"

Signed-off-by: Steven Slupsky <sslupsky@gmail.com>
This commit is contained in:
Steven Slupsky 2020-04-15 13:27:33 -06:00 committed by Carles Cufí
commit 4cd893021a

View file

@ -20,6 +20,10 @@
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Helper to pass a int as a pointer or vice-versa. */ /* Helper to pass a int as a pointer or vice-versa. */
#define POINTER_TO_UINT(x) ((uintptr_t) (x)) #define POINTER_TO_UINT(x) ((uintptr_t) (x))
#define UINT_TO_POINTER(x) ((void *) (uintptr_t) (x)) #define UINT_TO_POINTER(x) ((void *) (uintptr_t) (x))
@ -49,12 +53,13 @@
__typeof__(&(array)[0]))) __typeof__(&(array)[0])))
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C++" {
template < class T, size_t N > template < class T, size_t N >
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
constexpr constexpr
#endif /* >= C++11 */ #endif /* >= C++11 */
size_t ARRAY_SIZE(T(&)[N]) { return N; } size_t ARRAY_SIZE(T(&)[N]) { return N; }
}
#else #else
/* Evaluates to number of elements in an array; compile error if not /* Evaluates to number of elements in an array; compile error if not
* an array (e.g. pointer) * an array (e.g. pointer)
@ -968,4 +973,8 @@ u8_t u8_to_dec(char *buf, u8_t buflen, u8_t value);
z_rep_5, z_rep_4, z_rep_3, z_rep_2, z_rep_1, z_rep_0) \ z_rep_5, z_rep_4, z_rep_3, z_rep_2, z_rep_1, z_rep_0) \
(fixed_arg, x, ##__VA_ARGS__)} (fixed_arg, x, ##__VA_ARGS__)}
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_SYS_UTIL_H_ */ #endif /* ZEPHYR_INCLUDE_SYS_UTIL_H_ */