From: Christian Grothoff Date: Wed, 8 Apr 2020 12:47:01 +0000 (+0200) Subject: add GNUNET_static_assert() X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=17113fc2fd9d8607151dc4fecdbc161abb3b32fa;p=oweals%2Fgnunet.git add GNUNET_static_assert() --- diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 86d1a9f37..d84f9d77e 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h @@ -888,6 +888,28 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); } while (0) +#if HAVE_STATIC_ASSERT +/** + * Assertion to be checked (if supported by C compiler) at + * compile time, otherwise checked at runtime and resulting + * in an abort() on failure. + * + * @param cond condition to test, 0 implies failure + */ +#define GNUNET_static_assert(cond) _Static_assert (cond) +#else +/** + * Assertion to be checked (if supported by C compiler) at + * compile time, otherwise checked at runtime and resulting + * in an abort() on failure. This is the case where the + * compiler does not support static assertions. + * + * @param cond condition to test, 0 implies failure + */ +#define GNUNET_static_assert(cond) GNUNET_assert (cond) +#endif + + /** * @ingroup logging * Use this for internal assertion violations that are