diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2024-11-19 01:41:19 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2024-11-19 01:41:19 +0000 |
commit | 11d0ef193857975c82305ad0a08afb9228a87864 (patch) | |
tree | 32a282628e16c9a24fa7b5730d887872d348da04 | |
parent | 4f27f209516d141cc5aecc39af0e8baa27326b5c (diff) | |
parent | 480e4efd13ff06599be8201294a1757ca76cc74b (diff) | |
download | slirp-11d0ef193857975c82305ad0a08afb9228a87864.zip slirp-11d0ef193857975c82305ad0a08afb9228a87864.tar.gz slirp-11d0ef193857975c82305ad0a08afb9228a87864.tar.bz2 |
Merge branch 'vmstate-typeof-fix' into 'master'
vmstate.h: Prefer __typeof__ vice typeof
See merge request slirp/libslirp!145
-rw-r--r-- | src/vmstate.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/vmstate.h b/src/vmstate.h index cd77c85..82dcec7 100644 --- a/src/vmstate.h +++ b/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 |