diff options
author | Ran Benita <ran234@gmail.com> | 2014-08-09 22:35:24 +0300 |
---|---|---|
committer | Ran Benita <ran234@gmail.com> | 2014-08-09 22:42:45 +0300 |
commit | ead816e515683271665551037ee6ce431a880b61 (patch) | |
tree | 7cf9758fc2be54276dfde6a4af4c2fc97a3428d3 | |
parent | d38ff018b1a0a909d98631ee1d526bc56bc6e3d5 (diff) | |
download | libxkbcommon-ead816e515683271665551037ee6ce431a880b61.tar.gz libxkbcommon-ead816e515683271665551037ee6ce431a880b61.tar.bz2 libxkbcommon-ead816e515683271665551037ee6ce431a880b61.zip |
utils: add a STATIC_ASSERT macro
It'd be nicer to use C11's static_assert(), but it's easier to roll our
own C99 version using a trick I saw in xv6.
Signed-off-by: Ran Benita <ran234@gmail.com>
-rw-r--r-- | src/utils.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h index 51d690e..508435d 100644 --- a/src/utils.h +++ b/src/utils.h @@ -40,6 +40,10 @@ */ #define UNCONSTIFY(const_ptr) ((void *) (uintptr_t) (const_ptr)) +#define STATIC_ASSERT(expr, message) do { \ + switch (0) { case 0: case (expr): ; } \ +} while (0) + static inline bool streq(const char *s1, const char *s2) { |