From 315342ffedf6b81f629c42e87bfaedbcc7211646 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sat, 13 Dec 2025 19:56:09 +0100 Subject: [PATCH] Use correct preprocessor conditional in relptr.h When relptr.h was added (commit fbc1c12a94a), there was no check for HAVE_TYPEOF, so it used HAVE__BUILTIN_TYPES_COMPATIBLE_P, which already existed (commit ea473fb2dee) and which was thought to cover approximately the same compilers. But the guarded code can also work without HAVE__BUILTIN_TYPES_COMPATIBLE_P, and we now have a check for HAVE_TYPEOF (commit 4cb824699e1), so let's fix this up to use the correct logic. Co-authored-by: Thomas Munro Discussion: https://www.postgresql.org/message-id/CA%2BhUKGL7trhWiJ4qxpksBztMMTWDyPnP1QN%2BLq341V7QL775DA%40mail.gmail.com --- src/include/utils/relptr.h | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/include/utils/relptr.h b/src/include/utils/relptr.h index ea340fee657..48e394dba71 100644 --- a/src/include/utils/relptr.h +++ b/src/include/utils/relptr.h @@ -38,16 +38,12 @@ #define relptr_declare(type, relptrtype) \ typedef relptr(type) relptrtype -#ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P +#ifdef HAVE_TYPEOF #define relptr_access(base, rp) \ (AssertVariableIsOfTypeMacro(base, char *), \ - (__typeof__((rp).relptr_type)) ((rp).relptr_off == 0 ? NULL : \ + (typeof((rp).relptr_type)) ((rp).relptr_off == 0 ? NULL : \ (base) + (rp).relptr_off - 1)) #else -/* - * If we don't have __builtin_types_compatible_p, assume we might not have - * __typeof__ either. - */ #define relptr_access(base, rp) \ (AssertVariableIsOfTypeMacro(base, char *), \ (void *) ((rp).relptr_off == 0 ? NULL : (base) + (rp).relptr_off - 1)) @@ -72,16 +68,12 @@ relptr_store_eval(char *base, char *val) } } -#ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P +#ifdef HAVE_TYPEOF #define relptr_store(base, rp, val) \ (AssertVariableIsOfTypeMacro(base, char *), \ - AssertVariableIsOfTypeMacro(val, __typeof__((rp).relptr_type)), \ + AssertVariableIsOfTypeMacro(val, typeof((rp).relptr_type)), \ (rp).relptr_off = relptr_store_eval((base), (char *) (val))) #else -/* - * If we don't have __builtin_types_compatible_p, assume we might not have - * __typeof__ either. - */ #define relptr_store(base, rp, val) \ (AssertVariableIsOfTypeMacro(base, char *), \ (rp).relptr_off = relptr_store_eval((base), (char *) (val))) -- 2.39.5