make kmod compatible with GCC < 4.6
PATCH 1/1 make kmod compatible with GCC < 4.6
hello list, find attached a patch that fixes compilation with non-bleeding-edge compilers (we use GCC 4.5.4 in production).
the missing C11 feature is emulated on compilers that feature a __LINE__ macro.
best regards
--JS
[PATCH] make kmod compatible with GCC < 4.6
libkmod/macro.h +17 -0
@@ -21,8 +21,25 @@#include <stddef.h> +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ +0 >=201112L ) || \ + (defined(__GNUC__) && (__GNUC__ +0 ) *10 + (__GNUC_MINOR__ +0 ) >=46 ) +#define assert_cc (expr) \ _Static_assert((expr), #expr) + +#elif defined(__LINE__) + +#define PASTE2__ (A ,B ) A ## B +#define PASTE__ (A ,B ) PASTE2__(A, B) +#define STATIC_ASSERT__ (COND ) typedef char PASTE__(static_assertion, __LINE__) [(COND)?1:-1] +#define assert_cc (expr) \ + STATIC_ASSERT__((expr)) + +#else +#warning "compiler has no support for static assertions" +#define assert_cc (expr) do {} while(0) + +#endif #if HAVE_TYPEOF #define check_types_match (expr1, expr2) \
Hi John,
Quoted 5 lines · John Spencer
hello list, find attached a patch that fixes compilation with non-bleeding-edge compilers (we use GCC 4.5.4 in production).
the missing C11 feature is emulated on compilers that feature a
__LINE__macro.
there's a patch for this applied already, restoring our previous behavior. Doesn't it work for you? See dc8ed09 (Add configure check for _Static_assert())
Lucas De Marchi