From b780ba45bbb366406cd2ff42db3c69070ca2b22e Mon Sep 17 00:00:00 2001 From: Thomas Munro Date: Wed, 1 Apr 2026 22:20:55 +1300 Subject: [PATCH 1/3] Provide pg_attribute_deprecated("message") macro. This expands to C23/C++14 [[deprecated("message")]], or equivalent attributes available since GCC 4.9, Clang 2.9 and MSVC 2008 (and further back without a message). It can be placed before a type or function declaration to trigger compiler warnings when used. Backpatch-through: 14 --- src/include/c.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/include/c.h b/src/include/c.h index 88d13ec9993..67a759b1bf3 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -238,6 +238,21 @@ extern "C++" #define pg_attribute_target(...) #endif +/* + * Support for marking functions and types as deprecated, with a compiler + * warning if the function is used. Precedes a declaration. + */ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ + (defined(__cplusplus) && __cplusplus >= 201402L) +#define pg_attribute_deprecated(message) [[deprecated(message)]] +#elif defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 5) +#define pg_attribute_deprecated(message) __attribute__((deprecated(message))) +#elif defined(_MSC_VER) +#define pg_attribute_deprecated(message) __declspec(deprecated(message)) +#else +#define pg_attribute_deprecated(message) +#endif + /* * Append PG_USED_FOR_ASSERTS_ONLY to definitions of variables that are only * used in assert-enabled builds, to avoid compiler warnings about unused -- 2.53.0