]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
macro: Use C11 static_assert 23451/head
authorJan Janssen <medhefgo@web.de>
Fri, 20 May 2022 10:49:50 +0000 (12:49 +0200)
committerJan Janssen <medhefgo@web.de>
Fri, 20 May 2022 10:49:50 +0000 (12:49 +0200)
Now that we require C11 everywhere, we can always use static_assert.

src/fundamental/macro-fundamental.h

index 597429dc6c461d1f0a86a1d332833fad94326afd..083fca3e954645c3fee6257cbaacaefa48594b9c 100644 (file)
@@ -62,6 +62,7 @@
                 #define assert(expr) ({ _likely_(expr) ? VOID_0 : efi_assert(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); })
                 #define assert_not_reached() efi_assert("Code should not be reached", __FILE__, __LINE__, __PRETTY_FUNCTION__)
         #endif
+        #define static_assert _Static_assert
         #define assert_se(expr) ({ _likely_(expr) ? VOID_0 : efi_assert(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); })
 
         #define memcpy(a, b, c) CopyMem((a), (b), (c))
                 _expr_;                         \
         })
 
-#if defined(static_assert)
-#define assert_cc(expr)                                                 \
-        static_assert(expr, #expr)
-#else
-#define assert_cc(expr)                                                 \
-        struct CONCATENATE(_assert_struct_, __COUNTER__) {              \
-                char x[(expr) ? 0 : -1];                                \
-        }
-#endif
+#define assert_cc(expr) static_assert(expr, #expr)
+
 
 #define UNIQ_T(x, uniq) CONCATENATE(__unique_prefix_, CONCATENATE(x, uniq))
 #define UNIQ __COUNTER__