Portable StaticAssertExpr

Peter Eisentraut <peter@eisentraut.org>

Commit: aa7c86852343dd18f5834f70e4caa50ae49326c9
Author: Peter Eisentraut <peter@eisentraut.org>
Date: 2026-03-06T08:27:54Z
Portable StaticAssertExpr

Use a different way to write StaticAssertExpr() that does not require
the GCC extension statement expressions.

For C, we put the static_assert into a struct.  This appears to be a
common approach.

We still need to keep the fallback implementation to support buggy
MSVC < 19.33.

For C++, we put it into a lambda expression.  (The C approach doesn't
work; it's not permitted to define a new type inside sizeof.)

Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/5fa3a9f5-eb9a-4408-9baf-403d281f8b10%40eisentraut.org

Files

PathChange+/−
config/c-compiler.m4 modified +0 −16
configure modified +0 −31
configure.ac modified +0 −1
meson.build modified +0 −13
src/include/c.h modified +22 −8
src/include/pg_config.h.in modified +0 −3

Discussion