aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGilad Ben-Yossef <giladb@ezchip.com>2014-08-22 10:48:15 +0300
committerMaxim Uvarov <maxim.uvarov@linaro.org>2014-08-22 12:30:12 +0400
commit3ee9b44a2824457992bcafe7705b61d8e3be2b0c (patch)
tree3f6ccedb2bd05bfe37d89a73b96c46ffe8ed2677 /include
parent26238333b5b0896366c844aeb7253e60abd99f5a (diff)
odp_debug.h: backward compatible _Static_assert
Static_assert() support was only added to GCC 4.6. Provide a weak replcement for GCC users prior to that version, such as the default RHEL 6.x GCC, as it is better than breaking the build. The replacement macro is based on example from the following email: https://sourceware.org/ml/libc-alpha/2013-12/msg00102.html by Paul Eggert <eggart@cs.ucla.edu>, hence the CC. Signed-off-by: Gilad Ben-Yossef <giladb@ezchip.com> CC: Paul Eggert <eggert@cs.ucla.edu> CC: Barry Spinney <spinney@tilera.com>
Diffstat (limited to 'include')
-rw-r--r--include/odp_debug.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/odp_debug.h b/include/odp_debug.h
index 9a5ea2a8..e8f60036 100644
--- a/include/odp_debug.h
+++ b/include/odp_debug.h
@@ -30,6 +30,17 @@ extern "C" {
*/
#define ODP_UNUSED __attribute__((__unused__))
+#if __GNUC__ < 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ < 6))
+
+/**
+ * _Static_assert was only added in GCC 4.6. Provide a weak replacement
+ * for previous versions.
+ */
+#define _Static_assert(e, s) extern int (*static_assert_checker (void)) \
+ [sizeof (struct { unsigned int error_if_negative: (e) ? 1 : -1; })]
+
+#endif
+
#else
#define ODP_DEPRECATED