diff options
author | Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | 2013-09-06 15:27:04 +0200 |
---|---|---|
committer | Lucas De Marchi <lucas.demarchi@intel.com> | 2013-09-06 11:06:19 -0300 |
commit | dc8ed09f8f21d17ef9481001683d7edfdb308983 (patch) | |
tree | 1a8bf2807d8a3aea3d0a9daf39b105a1d2603cee /libkmod | |
parent | 7e0385c47ae7c313a59de3ea431af7b5d18807d7 (diff) | |
download | kmod-dc8ed09f8f21d17ef9481001683d7edfdb308983.tar.gz kmod-dc8ed09f8f21d17ef9481001683d7edfdb308983.tar.bz2 kmod-dc8ed09f8f21d17ef9481001683d7edfdb308983.zip |
Add configure check for _Static_assert()
Commit 8efede20ef ("Use _Static_assert") introduced the usage of
_Static_assert(). However, _Static_assert() is a fairly new thing,
since it was introduced only in gcc 4.6. In order to support older
compilers, this patch adds a configure.in test that checks whether
_Static_assert() is usable or not, and adjust the behavior of the
assert_cc() macro accordingly.
Diffstat (limited to 'libkmod')
-rw-r--r-- | libkmod/macro.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libkmod/macro.h b/libkmod/macro.h index c6ba855..10392a3 100644 --- a/libkmod/macro.h +++ b/libkmod/macro.h @@ -21,8 +21,13 @@ #include <stddef.h> +#if defined(HAVE_STATIC_ASSERT) #define assert_cc(expr) \ _Static_assert((expr), #expr) +#else +#define assert_cc(expr) \ + do { (void) sizeof(char [1 - 2*!(expr)]); } while(0) +#endif #if HAVE_TYPEOF #define check_types_match(expr1, expr2) \ |