]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blobdiff - rpp/include/base.h
Add STATIC_ASSERT macro
[pes-rpp/rpp-lib.git] / rpp / include / base.h
index cde2dec50519d87dd3cfb99fd9befa1ff11f6ac1..38d401b49077981690ea628c4bf7f0b9fa7f351f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * @file base.h
  *
- * @copyright Copyright (C) 2013 Czech Technical University in Prague
+ * @copyright Copyright (C) 2013, 2015 Czech Technical University in Prague
  *
  * @author Carlos Jenkins <carlos@jenkins.co.cr>
  */
@@ -15,6 +15,7 @@
 #include "types.h"
 #include "binary.h"
 #include "os/os.h"
+#include <assert.h>
 
 // General IO directives
 /**
 
 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(*(x)))
 
+#if defined(static_assert)
+/* C11 static_assert available */
+#define STATIC_ASSERT(COND,MSG) static_assert(COND, #MSG)
+#else
+/* Non-C11 fall-back */
+#define STATIC_ASSERT(COND,MSG) typedef char static_assertion_##MSG[(COND)?1:-1]
+#endif
+
 #endif /* __BASE_H */