summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-07-25 21:48:27 +0200
committerDaniel Stone <daniels@collabora.com>2024-01-19 14:21:59 +0000
commit56b9c92b9881527d05ea9caa34c2c87e5927aa71 (patch)
tree37b938019720f6cffe9902a859136670c4bd0cdc
parentdc1da181db066415edfb73f4d9a579bc7b72b223 (diff)
util: use C23 typeof if available
Instead of using the non-standard __typeof__, prefer the standard typeof operator introduced in C23. Signed-off-by: Simon Ser <contact@emersion.fr>
-rw-r--r--src/wayland-util.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/wayland-util.h b/src/wayland-util.h
index 1a451e4..79aabc7 100644
--- a/src/wayland-util.h
+++ b/src/wayland-util.h
@@ -68,6 +68,12 @@ extern "C" {
#define WL_PRINTF(x, y)
#endif
+#if __STDC_VERSION__ >= 202311L
+#define WL_TYPEOF(expr) typeof(expr)
+#else
+#define WL_TYPEOF(expr) __typeof__(expr)
+#endif
+
/** \class wl_object
*
* \brief A protocol object.
@@ -406,8 +412,8 @@ wl_list_insert_list(struct wl_list *list, struct wl_list *other);
* \return The container for the specified pointer
*/
#define wl_container_of(ptr, sample, member) \
- (__typeof__(sample))((char *)(ptr) - \
- offsetof(__typeof__(*sample), member))
+ (WL_TYPEOF(sample))((char *)(ptr) - \
+ offsetof(WL_TYPEOF(*sample), member))
/**
* Iterates over a list.