summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-19 01:10:22 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-20 19:36:14 +0100
commit780dbeef9f9d2c9f416da50a07bf0aacf3cc66c7 (patch)
treedce4b644fe10188d5d23c6b8b204aa2d0bbb0d39
parentfd1b903adb6f7b06d263fcb6a4ae01d734b2c8d4 (diff)
macro: change assert_cc() so that it can appear outside of functions
-rw-r--r--src/shared/macro.h14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 9e94495dd6..37cdff1cb3 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -143,19 +143,9 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
} while (false)
#if defined(static_assert)
-#define assert_cc(expr) \
- do { \
- static_assert(expr, #expr); \
- } while (false)
+#define assert_cc(expr) static_assert(expr, #expr)
#else
-#define assert_cc(expr) \
- do { \
- switch (0) { \
- case 0: \
- case !!(expr): \
- ; \
- } \
- } while (false)
+#define assert_cc(expr) struct _assert_struct_ ## __LINE__ { char x[(expr) ? 0 : -1]; }
#endif
#define assert_return(expr, r) \