From 45c96ea279e95aa499856f9062f743665fd564ee Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 19 Mar 2014 10:59:31 -0700 Subject: [PATCH 1/2] Approximate _Static_assert for pre-C11 compilers. * misc/sys/cdefs.h (_Static_assert) [__STDC_VERSION__ < 201112L]: New macro, for convenience with pre-C11 compilers. --- ChangeLog | 6 ++++++ misc/sys/cdefs.h | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/ChangeLog b/ChangeLog index f48f6bb..3d4c88d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-03-19 Paul Eggert + + Approximate _Static_assert for pre-C11 compilers. + * misc/sys/cdefs.h (_Static_assert) [__STDC_VERSION__ < 201112L]: + New macro, for convenience with pre-C11 compilers. + 2014-03-19 Joseph Myers * math/libm-test.inc (fdim_test): Use ALL_RM_TEST. diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index 4d958ea..9402520 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -382,6 +382,13 @@ # define __glibc_likely(cond) (cond) #endif +#if ! (defined _Static_assert \ + || (defined __STDC_VERSION__ && 201112L <= __STDC_VERSION__) \ + || (__GNUC_PREREQ (4, 6) && !defined __STRICT_ANSI__)) +# define _Static_assert(e, s) extern int (*__glibc_Static_assert (void)) \ + [sizeof (struct { unsigned int _Static_assert_failure: (e) ? 1 : -1; })] +#endif + #include #if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH -- 1.8.5.3