summaryrefslogtreecommitdiffstats
path: root/src/diag.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-05-11 14:07:54 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-05-16 11:29:31 -0400
commit72cd1c2a584d89e76a5e9e7deaf07ddc4196d1aa (patch)
tree6cc8a291a2276d05790ba738637c65d5775f3620 /src/diag.h
parenta7932050f65844fb1f1145fee87c72aadaf4f995 (diff)
downloadbfs-72cd1c2a584d89e76a5e9e7deaf07ddc4196d1aa.tar.xz
diag: New bfs_static_assert() macro
Diffstat (limited to 'src/diag.h')
-rw-r--r--src/diag.h12
1 files changed, 11 insertions, 1 deletions
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 <stdarg.h>
+/**
+ * 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;
/**