From 3ba88bb314f6ba4824388917c3870ef9aa02e5b8 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Tue, 8 Sep 2015 22:41:50 +0200 Subject: [PATCH] Extracted GCC-specific pragma from the assert macro --- include/criterion/assert.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/criterion/assert.h b/include/criterion/assert.h index 8c28e30..82216e8 100644 --- a/include/criterion/assert.h +++ b/include/criterion/assert.h @@ -90,6 +90,12 @@ struct criterion_assert_args { # define CR_FAIL_ABORT_ criterion_abort_test # define CR_FAIL_CONTINUES_ criterion_continue_test +# ifdef __GNUC__ +// We disable the format-zero-length warning because we use the validity of +// asprintf(out, "") for empty assertion messages +# pragma GCC diagnostic ignored "-Wformat-zero-length" +# endif + # define cr_assert_impl(Fail, Condition, ...) \ do { \ bool passed = !!(Condition); \ @@ -97,7 +103,6 @@ struct criterion_assert_args { const char *msg = NULL; \ size_t bufsize; \ \ - _Pragma("GCC diagnostic ignored \"-Wformat-zero-length\"") \ struct criterion_assert_stats *stat; \ CR_EXPAND(CR_INIT_STATS_(bufsize, msg, CR_VA_TAIL(__VA_ARGS__))); \ stat->passed = passed; \