summaryrefslogtreecommitdiff
path: root/include/nsutils
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2022-03-26 16:17:32 +0000
committerMichael Drake <michael.drake@codethink.co.uk>2022-03-26 16:17:32 +0000
commit73215930a3f45735ddc31b439111e575d73ab6f3 (patch)
treefe0c674156721d823c2f11bed10920761417bdf3 /include/nsutils
parentb320babd590a54588a3f568aa31f854133e850f2 (diff)
downloadlibnsutils-73215930a3f45735ddc31b439111e575d73ab6f3.tar.gz
libnsutils-73215930a3f45735ddc31b439111e575d73ab6f3.tar.bz2
Assert: Add static assertion macro.
We're not C11 so we can't use static_assert().
Diffstat (limited to 'include/nsutils')
-rw-r--r--include/nsutils/assert.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/nsutils/assert.h b/include/nsutils/assert.h
new file mode 100644
index 0000000..0f8f14d
--- /dev/null
+++ b/include/nsutils/assert.h
@@ -0,0 +1,24 @@
+/*
+ * This file is part of LibNSUtils.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2022 Michael Drake <tlsa@netsurf-browser.org>
+ */
+
+/**
+ * \file
+ * Static assertion macro.
+ */
+
+#ifndef NSUTILS_ASSERT_H__
+#define NSUTILS_ASSERT_H__
+
+/** Compile time assertion macro. */
+#define ns_static_assert(e) \
+{ \
+ enum { \
+ cyaml_static_assert_check = 1 / (!!(e)) \
+ }; \
+}
+
+#endif