Make macro assert_cc() not emit "declaration after statements" warnings.
This can be done by using the GCC pragmas 'diagnostic ignore "undefined"'. In order to be able to use that pragma inside a macro, we need to put it into the (C99-introduced) _Pragma() pseudo-function. --- src/shared/macro.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/shared/macro.h b/src/shared/macro.h index dfbc201..f93a4f0 100644 --- a/src/shared/macro.h +++ b/src/shared/macro.h @@ -156,7 +156,11 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) { #if defined(static_assert) #define assert_cc(expr) static_assert(expr, #expr) #else -#define assert_cc(expr) struct UNIQUE(_assert_struct_) { char x[(expr) ? 0 : -1]; }; +#define assert_cc(expr) \ + _Pragma("GCC diagnostic push"); \ + _Pragma("GCC diagnostic ignored \"-Wdeclaration-after-statement\""); \ + struct UNIQUE(_assert_struct_) { char x[(expr) ? 0 : -1]; }; \ + _Pragma("GCC diagnostic pop"); #endif #define assert_return(expr, r) \ -- 1.7.10.4 _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel