From 50c1daf6535084e00cd2e1ff97a4f84bccdaf700 Mon Sep 17 00:00:00 2001 From: leitner Date: Wed, 8 Apr 2020 11:37:31 +0000 Subject: [PATCH] use _Static_assert if available --- compiletimeassert.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiletimeassert.h b/compiletimeassert.h index 977356d..f9cfb49 100644 --- a/compiletimeassert.h +++ b/compiletimeassert.h @@ -1,4 +1,12 @@ +#if __STDC_VERSION__ >= 201112L + +#define compiletimeassert(cond) _Static_assert(cond) + +#else + #define __X(x, y) x ## y #define __Y(x, y) __X(x, y) #define compiletimeassert(cond) struct __Y(foo,__LINE__) { char __temp[1 - (!(cond))*2]; }; + +#endif