diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2015-02-05 15:52:20 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2015-02-07 14:43:27 -0800 |
commit | 3999d26ead93990b244ada078073fb58fb8bb5be (patch) | |
tree | fb49ba47c9d88204c23135ef44ac4adf7919120e /misc/sys | |
parent | f96ec27aa9f8fe871973b898ee407fe17681b6a7 (diff) | |
download | glibc-3999d26ead93990b244ada078073fb58fb8bb5be.tar.gz glibc-3999d26ead93990b244ada078073fb58fb8bb5be.tar.xz glibc-3999d26ead93990b244ada078073fb58fb8bb5be.zip |
Add ersatz _Static_assert on older C hosts
* misc/sys/cdefs.h (_Static_assert): Define a substitute, if on a pre-C11 C platform that is not known to support _Static_assert.
Diffstat (limited to 'misc/sys')
-rw-r--r-- | misc/sys/cdefs.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index 09ee352e1f..99e94cce86 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -399,6 +399,14 @@ # endif #endif +#if (!defined _Static_assert && !defined __cplusplus \ + && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \ + && (!__GNUC_PREREQ (4, 6) || defined __STRICT_ANSI__)) +# define _Static_assert(expr, diagnostic) \ + extern int (*__Static_assert_function (void)) \ + [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })] +#endif + #include <bits/wordsize.h> #if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH |