[rtems commit] score: Support static_assert and _Static_assert

Sebastian Huber sebh at rtems.org
Tue Nov 6 09:20:55 UTC 2012


Module:    rtems
Branch:    master
Commit:    e278f8b7d9456cb7d051da06a4b011b9568831dc
Changeset: http://git.rtems.org/rtems/commit/?id=e278f8b7d9456cb7d051da06a4b011b9568831dc

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Sun Nov  4 19:56:34 2012 +0100

score: Support static_assert and _Static_assert

---

 cpukit/score/include/rtems/score/basedefs.h |   12 ++++++++++--
 1 files 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




More information about the vc mailing list