[Git][slirp/libslirp][master] 2 commits: vmstate.h: Prefer __typeof__ vice typeof

Samuel Thibault (@sthibaul) gitlab at gitlab.freedesktop.org
Tue Nov 19 01:41:23 UTC 2024



Samuel Thibault pushed to branch master at slirp / libslirp


Commits:
480e4efd by B. Scott Michel at 2024-11-18T11:59:16-08:00
vmstate.h: Prefer __typeof__ vice typeof

Clang masquerading as gcc on macOS (i.e., "gcc") borks on typeof(), but
happily accepts __typeof__().

N.B., __typeof__ has been accepted by GCC and Clang for a long time, and
recently MS decided to support it as well.

- - - - -
11d0ef19 by Samuel Thibault at 2024-11-19T01:41:19+00:00
Merge branch 'vmstate-typeof-fix' into 'master'

vmstate.h: Prefer __typeof__ vice typeof

See merge request slirp/libslirp!145
- - - - -


1 changed file:

- src/vmstate.h


Changes:

=====================================
src/vmstate.h
=====================================
@@ -216,10 +216,16 @@ extern const VMStateInfo slirp_vmstate_info_nullptr;
 extern const VMStateInfo slirp_vmstate_info_buffer;
 extern const VMStateInfo slirp_vmstate_info_tmp;
 
-#ifdef __GNUC__
+/* __typeof__ is recommended for better portability over typeof.
+ *
+ * __typeof__ is available in GCC, Clang, Clang masquerading as gcc on macOS,
+ * as well as MSVC version 19.39.33428+. It's also part of C23.
+ */
+#if defined(__GNUC__) || defined(__clang__) || (_MSC_FULL_VER >= 193933428) || \
+    (__STDC_VERSION__ >= 202301L)
 #define type_check_array(t1, t2, n) ((t1(*)[n])0 - (t2 *)0)
 #define type_check_pointer(t1, t2) ((t1 **)0 - (t2 *)0)
-#define typeof_field(type, field) typeof(((type *)0)->field)
+#define typeof_field(type, field) __typeof__(((type *)0)->field)
 #define type_check(t1, t2) ((t1 *)0 - (t2 *)0)
 #else
 #define type_check_array(t1, t2, n) 0



View it on GitLab: https://gitlab.freedesktop.org/slirp/libslirp/-/compare/4f27f209516d141cc5aecc39af0e8baa27326b5c...11d0ef193857975c82305ad0a08afb9228a87864

-- 
View it on GitLab: https://gitlab.freedesktop.org/slirp/libslirp/-/compare/4f27f209516d141cc5aecc39af0e8baa27326b5c...11d0ef193857975c82305ad0a08afb9228a87864
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/slirp/attachments/20241119/5750305a/attachment-0001.htm>


More information about the Slirp mailing list