summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorMichael Brown2024-01-16 13:23:02 +0100
committerMichael Brown2024-01-16 14:35:08 +0100
commit6d29415c89d607b988381bc367c9c521694fa728 (patch)
treeab4a300dc7856a6fcbeb8b6f4db002e70d2f4e86 /src/include
parent[build] Fix building with newer binutils (diff)
downloadipxe-6d29415c89d607b988381bc367c9c521694fa728.tar.gz
ipxe-6d29415c89d607b988381bc367c9c521694fa728.tar.xz
ipxe-6d29415c89d607b988381bc367c9c521694fa728.zip
[libc] Make static_assert() available via assert.h
Expose static_assert() via assert.h and migrate link-time assertions to build-time assertions where possible. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/assert.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/include/assert.h b/src/include/assert.h
index dd71fa71..6d053180 100644
--- a/src/include/assert.h
+++ b/src/include/assert.h
@@ -56,6 +56,15 @@ assert_printf ( const char *fmt, ... ) asm ( "printf" );
} while ( 0 )
/**
+ * Assert a condition at build time
+ *
+ * If the compiler cannot prove that the condition is true, the build
+ * will fail with an error message.
+ */
+#undef static_assert
+#define static_assert(x) _Static_assert( x, #x )
+
+/**
* Assert a condition at link-time.
*
* If the condition is not true, the link will fail with an unresolved