Add a wrapper for _Static_assert() to use within nolibc.
While _Static_assert() itself was only standardized in C11,
in GCC and clang dialects it is also available in older standards.

If it turns out that _Static_assert can't be used in some contexts,
this wrapper can be adapted.

Signed-off-by: Thomas Weißschuh <[email protected]>
---
 tools/include/nolibc/compiler.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compiler.h
index 87090bbc53e0..ef247e916552 100644
--- a/tools/include/nolibc/compiler.h
+++ b/tools/include/nolibc/compiler.h
@@ -47,4 +47,6 @@
 #  define __nolibc_fallthrough do { } while (0)
 #endif /* __nolibc_has_attribute(fallthrough) */
 
+#define __nolibc_static_assert(_t) _Static_assert(_t, "")
+
 #endif /* _NOLIBC_COMPILER_H */

-- 
2.52.0


Reply via email to