From 72cd1c2a584d89e76a5e9e7deaf07ddc4196d1aa Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 11 May 2023 14:07:54 -0400 Subject: diag: New bfs_static_assert() macro --- src/diag.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/diag.h') diff --git a/src/diag.h b/src/diag.h index 987d4b4..a086942 100644 --- a/src/diag.h +++ b/src/diag.h @@ -2,7 +2,7 @@ // SPDX-License-Identifier: 0BSD /** - * Formatters for diagnostic messages. + * Diagnostic messages. */ #ifndef BFS_DIAG_H @@ -12,6 +12,16 @@ #include "config.h" #include +/** + * static_assert() with an optional second argument. + */ +#if __STDC_VERSION__ >= 202311L +# define bfs_static_assert static_assert +#else +# define bfs_static_assert(...) BFS_STATIC_ASSERT(__VA_ARGS__, #__VA_ARGS__, ) +# define BFS_STATIC_ASSERT(expr, msg, ...) _Static_assert(expr, msg) +#endif + struct bfs_expr; /** -- cgit v1.2.3