From 691b6ef34206f71f9306085ca151c9f929ca73bc Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 14 Aug 2020 12:59:29 -0700 Subject: [PATCH] macros: simplify static assert fallback to use __COUNTER__ It is rather annoying that the other sizeof form doesn't work with Clang. This at least gets things working (assuming you have __COUNTER__ support) which most things we care about do at this point (including MSVC). --- src/libsysprof-capture/sysprof-macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsysprof-capture/sysprof-macros.h b/src/libsysprof-capture/sysprof-macros.h index c5198241..7ffc7c34 100644 --- a/src/libsysprof-capture/sysprof-macros.h +++ b/src/libsysprof-capture/sysprof-macros.h @@ -75,7 +75,7 @@ #elif SYSPROF_GNUC_CHECK_VERSION(4, 6) # define SYSPROF_STATIC_ASSERT(expr, msg) _Static_assert(expr, msg) #else -# define SYSPROF_STATIC_ASSERT(expr, msg) ((void) sizeof (char[(expr) ? 1 : -1])) +# define SYSPROF_STATIC_ASSERT(expr, msg) char __static_assert_##__COUNTER__ [(expr) ? 0 : -1]; #endif #if INT_MAX == LONG_MAX