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 <[email protected]>, hence the CC.

Signed-off-by: Gilad Ben-Yossef <[email protected]>
CC: Paul Eggert <[email protected]>
CC: Barry Spinney <[email protected]>
---
 include/odp_debug.h |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/include/odp_debug.h b/include/odp_debug.h
index 9a5ea2a..e8f6003 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
-- 
1.7.1


_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to