summaryrefslogtreecommitdiff
path: root/src/basicmacros.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/basicmacros.h')
-rw-r--r--src/basicmacros.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/basicmacros.h b/src/basicmacros.h
index cebf06043..2a30a31d2 100644
--- a/src/basicmacros.h
+++ b/src/basicmacros.h
@@ -38,4 +38,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
C(const C &); \
C &operator=(const C &)
+// Fail compilation if condition expr is not met.
+// Note that 'msg' must follow the format of a valid identifier, e.g.
+// STATIC_ASSERT(sizeof(foobar_t) == 40), foobar_t_is_wrong_size);
+#define STATIC_ASSERT(expr, msg) typedef char msg[!!(expr) * 2 - 1]
+
#endif