chiark
/
gitweb
/
~mdw
/
mLib
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
utils/macros.h: Introduce a `STATIC_ASSERT' macro.
[mLib]
/
utils
/
macros.h
diff --git
a/utils/macros.h
b/utils/macros.h
index 5f432f7e9b3c25b82884214df5bb3d388702add9..9e27a4813a4b3f8997e2ba85784d587023d87778 100644
(file)
--- a/
utils/macros.h
+++ b/
utils/macros.h
@@
-34,6
+34,8
@@
/*----- Header files ------------------------------------------------------*/
/*----- Header files ------------------------------------------------------*/
+#include <assert.h>
+
#ifndef MLIB_COMPILER_H
# include "compiler.h"
#endif
#ifndef MLIB_COMPILER_H
# include "compiler.h"
#endif
@@
-48,6
+50,13
@@
#define MLIB__GLUE(x, y) x##y
#define GLUE(x, y) MLIB__GLUE(x, y)
#define MLIB__GLUE(x, y) x##y
#define GLUE(x, y) MLIB__GLUE(x, y)
+#ifdef static_assert
+# define STATIC_ASSERT(cond, msg) static_assert(cond, msg)
+#else
+# define STATIC_ASSERT(cond, msg) \
+ IGNORABLE extern char static_assert_failed[2*!!(cond) - 1]
+#endif
+
/*----- Compiler diagnostics ----------------------------------------------*/
/* --- Compiler-specific definitions --- */
/*----- Compiler diagnostics ----------------------------------------------*/
/* --- Compiler-specific definitions --- */