From 907cd3dd01098c5b7437173b5f800ecdf03946bb Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 7 Nov 2014 19:40:11 -0800 Subject: Add a workaround for compilers without __COUNTER__ This can make GCC pretty noisey, complaining "declaration does not declare anything" for each static_assert, but it should still function on such older compilers. --- include/static_assert.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/static_assert.h b/include/static_assert.h index 65283cf0..12a095a3 100644 --- a/include/static_assert.h +++ b/include/static_assert.h @@ -7,10 +7,12 @@ #ifndef static_assert #ifdef HAVE_C11_STATIC_ASSERT #define static_assert _Static_assert -#else +#elif defined(__COUNTER__) #define CTASTR2(_pre,_post) _pre##_post #define CTASTR(_pre,_post) CTASTR2(_pre,_post) #define static_assert(_cond, _msg) typedef struct { int CTASTR(static_assert_failed_at_line_,__LINE__) : !!(_cond); } CTASTR(static_assertion_,__COUNTER__) +#else +#define static_assert(_cond, _msg) struct { int CTASTR(static_assert_failed_at_line_,__LINE__) : !!(_cond); } #endif #endif -- cgit v1.2.3