diff options
Diffstat (limited to 'lib/compiler.h')
| -rw-r--r-- | lib/compiler.h | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/lib/compiler.h b/lib/compiler.h index 70ef8e9bc8..b7a142bdee 100644 --- a/lib/compiler.h +++ b/lib/compiler.h @@ -21,6 +21,21 @@ extern "C" { #endif +#ifdef __cplusplus +# if __cplusplus < 201103L +# error FRRouting headers must be compiled in C++11 mode or newer +# endif +/* C++ defines static_assert(), but not _Static_assert(). C defines + * _Static_assert() and has static_assert() in <assert.h>. However, we mess + * with assert() in zassert.h so let's not include <assert.h> here. + */ +# define _Static_assert static_assert +#else +# if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L +# error FRRouting must be compiled with min. -std=gnu11 (GNU ISO C11 dialect) +# endif +#endif + /* function attributes, use like * void prototype(void) __attribute__((_CONSTRUCTOR(100))); */ @@ -121,6 +136,24 @@ extern "C" { #define macro_inline static inline __attribute__((unused)) #define macro_pure static inline __attribute__((unused, pure)) +/* if the macro ends with a function definition */ +#define MACRO_REQUIRE_SEMICOLON() \ + _Static_assert(1, "please add a semicolon after this macro") + +#if CONFDATE < 20210601 +#ifdef ENABLE_BGP_VNC +/* temporarily disabled for transition for LabN CI + * NB: it's not possible to generate a deprecation warning for this, hence + * the shortened transition period (since otherwise new uses of the old syntax + * may creep in without errors) + */ +#undef MACRO_REQUIRE_SEMICOLON +#define MACRO_REQUIRE_SEMICOLON() \ + /* nothing */ +#endif /* ENABLE_BGP_VNC */ +#else /* CONFDATE >= 20210601 */ +CPP_NOTICE("time to remove this CONFDATE block") +#endif /* variadic macros, use like: * #define V_0() ... @@ -357,10 +390,8 @@ typedef signed long long _int64_t; /* if this breaks, 128-bit machines may have entered reality (or <long long> * is something weird) */ -#if __STDC_VERSION__ >= 201112L _Static_assert(sizeof(_uint64_t) == 8 && sizeof(_int64_t) == 8, "nobody expects the spanish intquisition"); -#endif /* since we redefined int64_t, we also need to redefine PRI*64 */ #undef PRIu64 |
