[sheepdog] [PATCH 2/3] util: add BUILD_BUG_ON() for detecting errors at compile time
Hitoshi Mitake
mitake.hitoshi at gmail.com
Sun Apr 28 19:08:06 CEST 2013
This patch adds BUILD_BUG_ON() to include/util.h. The macro can be
used for detecting errors which should cause build
error. e.g. checking struct sizes, etc.
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
include/util.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/util.h b/include/util.h
index 1bdaf36..68eface 100644
--- a/include/util.h
+++ b/include/util.h
@@ -176,4 +176,8 @@ static inline bool is_stdout_console(void)
extern mode_t sd_def_fmode;
extern mode_t sd_def_dmode;
+
+/* Force a compilation error if the condition is true */
+#define BUILD_BUG_ON(condition) ((void)sizeof(struct { int: -!!(condition); }))
+
#endif
--
1.7.10.rc0.41.gfa678
More information about the sheepdog
mailing list