aboutsummaryrefslogtreecommitdiff
path: root/fsm/tk.h
diff options
context:
space:
mode:
Diffstat (limited to 'fsm/tk.h')
-rw-r--r--fsm/tk.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/fsm/tk.h b/fsm/tk.h
index 785808d..f2e7efe 100644
--- a/fsm/tk.h
+++ b/fsm/tk.h
@@ -24,3 +24,17 @@
// use it like this:
//#include incfile(CONFIGFILE)
+
+// cause a build failure if `condition` is true
+// (gcc compile trick taken from an old version of include/linux/kernel.h)
+// more info here:
+// https://scaryreasoner.wordpress.com/2009/02/28/checking-sizeof-at-compile-time/
+#define BUILD_FAIL_IF(name, condition) \
+ __attribute__((unused)) static void name() \
+ { ((void)sizeof(char[1 - 2*!!(condition)])); }
+
+// cause a build failure if `condition` is false
+#define BUILD_ASSERT(name, condition) \
+ __attribute__((unused)) static void name() \
+ { ((void)sizeof(char[1 - 2*!(condition)])); }
+