[PATCH] score: Support static_assert and _Static_assert

Sebastian Huber sebastian.huber at embedded-brains.de
Sun Nov 4 18:56:34 UTC 2012


---
 cpukit/score/include/rtems/score/basedefs.h |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/cpukit/score/include/rtems/score/basedefs.h b/cpukit/score/include/rtems/score/basedefs.h
index 1f8660c..8239994 100644
--- a/cpukit/score/include/rtems/score/basedefs.h
+++ b/cpukit/score/include/rtems/score/basedefs.h
@@ -163,8 +163,16 @@
   #define RTEMS_COMPILER_DEPRECATED_ATTRIBUTE
 #endif
 
-#define RTEMS_STATIC_ASSERT(cond, msg) \
-  typedef int rtems_static_assert_ ## msg [(cond) ? 1 : -1]
+#if __cplusplus >= 201103L
+  #define RTEMS_STATIC_ASSERT(cond, msg) \
+    static_assert(cond, # msg)
+#elif __STDC_VERSION__ >= 201112L
+  #define RTEMS_STATIC_ASSERT(cond, msg) \
+    _Static_assert(cond, # msg)
+#else
+  #define RTEMS_STATIC_ASSERT(cond, msg) \
+    typedef int rtems_static_assert_ ## msg [(cond) ? 1 : -1]
+#endif
 
 #ifndef ASM
   #ifdef RTEMS_DEPRECATED_TYPES
-- 
1.7.10.4




More information about the devel mailing list