]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Use typeof everywhere instead of compiler specific spellings
authorPeter Eisentraut <peter@eisentraut.org>
Fri, 6 Mar 2026 09:13:49 +0000 (10:13 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Fri, 6 Mar 2026 09:14:32 +0000 (10:14 +0100)
We define typeof ourselves as __typeof__ if it does not exist.  So
let's actually use that for consistency.  The meson/autoconf checks
for __builtin_types_compatible_p still use __typeof__ though, because
there we have not redefined it.

Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/CAGECzQR21OnnKiZO_1rLWO0-16kg1JBxnVq-wymYW0-_1cUNtg@mail.gmail.com

src/include/c.h

index c00a9ecf21dfb17f99e9316824ea2e72955fe3a3..631ead8db7991e345b0fd6855d33c36f279be7aa 100644 (file)
@@ -1022,10 +1022,10 @@ pg_noreturn extern void ExceptionalCondition(const char *conditionName,
  */
 #ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P
 #define StaticAssertVariableIsOfType(varname, typename) \
-       StaticAssertDecl(__builtin_types_compatible_p(__typeof__(varname), typename), \
+       StaticAssertDecl(__builtin_types_compatible_p(typeof(varname), typename), \
        CppAsString(varname) " does not have type " CppAsString(typename))
 #define StaticAssertVariableIsOfTypeMacro(varname, typename) \
-       (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
+       (StaticAssertExpr(__builtin_types_compatible_p(typeof(varname), typename), \
         CppAsString(varname) " does not have type " CppAsString(typename)))
 #else                                                  /* !HAVE__BUILTIN_TYPES_COMPATIBLE_P */
 #define StaticAssertVariableIsOfType(varname, typename) \
@@ -1289,11 +1289,11 @@ typedef struct PGAlignedXLogBlock PGAlignedXLogBlock;
 #define unvolatize(underlying_type, expr) const_cast<underlying_type>(expr)
 #elif defined(HAVE__BUILTIN_TYPES_COMPATIBLE_P)
 #define unconstify(underlying_type, expr) \
-       (StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), const underlying_type), \
+       (StaticAssertExpr(__builtin_types_compatible_p(typeof(expr), const underlying_type), \
                                          "wrong cast"), \
         (underlying_type) (expr))
 #define unvolatize(underlying_type, expr) \
-       (StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), volatile underlying_type), \
+       (StaticAssertExpr(__builtin_types_compatible_p(typeof(expr), volatile underlying_type), \
                                          "wrong cast"), \
         (underlying_type) (expr))
 #else