Fix for C++ compatibility
authorPeter Eisentraut <peter@eisentraut.org>
Wed, 21 Jan 2026 07:32:45 +0000 (08:32 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Wed, 21 Jan 2026 07:54:35 +0000 (08:54 +0100)
After commit 476b35d4e31, some buildfarm members are complaining about
not recognizing _Noreturn when building the new C++ module
test_cplusplusext.  This is not a C++ feature, but it was gated like

    #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
    #define pg_noreturn _Noreturn

But apparently that was not sufficient.  Some platforms define
__STDC_VERSION__ even in C++ mode.  (In this particular case, it was
g++ on Solaris, but apparently this is also done by some other
platforms, and it is allowed by the C++ standard.)  To fix, add a

    ... && !defined(__cplusplus)

Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/flat/CAGECzQR21OnnKiZO_1rLWO0-16kg1JBxnVq-wymYW0-_1cUNtg@mail.gmail.com

src/include/c.h

index 7136102e5ff2a900deef409845d22f4948149d19..13fbeea408e8ab8fbb9e551ca26807b367374585 100644 (file)
  * common style is to put them before the return type.  (The MSVC fallback has
  * the same requirement.  The GCC fallback is more flexible.)
  */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) && !defined(__cplusplus)
 #define pg_noreturn _Noreturn
 #elif defined(__GNUC__)
 #define pg_noreturn __attribute__((noreturn))