[sysprof] macros: simplify static assert fallback to use __COUNTER__
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] macros: simplify static assert fallback to use __COUNTER__
- Date: Fri, 14 Aug 2020 19:59:39 +0000 (UTC)
commit 691b6ef34206f71f9306085ca151c9f929ca73bc
Author: Christian Hergert <chergert redhat com>
Date: Fri Aug 14 12:59:29 2020 -0700
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]