From c1d0653c87541ac6db8ab822464bc3269b1fb675 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 24 Feb 2026 16:56:49 +0100 Subject: [PATCH 1/2] [winpr,platform] fix C23 checks https://en.cppreference.com/w/c/language/attributes.html has a nice overview of attributes and when they were introduced. Adjust macro checks accordingly. --- winpr/include/winpr/platform.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/winpr/include/winpr/platform.h b/winpr/include/winpr/platform.h index e95f82efa..e96d305ac 100644 --- a/winpr/include/winpr/platform.h +++ b/winpr/include/winpr/platform.h @@ -76,7 +76,7 @@ #endif #if defined(WINPR_DEFINE_ATTR_NODISCARD) -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201904L) +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202003L) #define WINPR_ATTR_NODISCARD [[nodiscard]] #elif defined(__clang__) #define WINPR_ATTR_NODISCARD __attribute__((warn_unused_result)) @@ -539,7 +539,9 @@ WINPR_PRAGMA_DIAG_POP #define WINPR_DEPRECATED_VAR(text, obj) obj #endif -#if defined(WIN32) && !defined(__CYGWIN__) +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202202L) +#define WINPR_NORETURN(obj) [[noreturn]] obj +#elif defined(WIN32) && !defined(__CYGWIN__) #define WINPR_NORETURN(obj) __declspec(noreturn) obj #elif defined(__GNUC__) #define WINPR_NORETURN(obj) __attribute__((__noreturn__)) obj @@ -641,7 +643,7 @@ WINPR_PRAGMA_DIAG_POP #if defined(__cplusplus) && (__cplusplus >= 201703L) #define WINPR_ATTR_UNUSED [[maybe_unused]] /** @since version 3.12.0 */ -#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202000L) +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201904L) #define WINPR_ATTR_UNUSED [[maybe_unused]] /** @since version 3.12.0 */ #elif defined(__GNUC__) || defined(__clang__) #define WINPR_ATTR_UNUSED __attribute__((unused)) /** @since version 3.12.0 */ From 3c84d08518007d13484a7502ea0206f3053f3a9c Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 24 Feb 2026 17:03:56 +0100 Subject: [PATCH 2/2] [winpr,platform] add C++ guards for macros define attributes when included from C++ code --- winpr/include/winpr/platform.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/winpr/include/winpr/platform.h b/winpr/include/winpr/platform.h index e96d305ac..17990104c 100644 --- a/winpr/include/winpr/platform.h +++ b/winpr/include/winpr/platform.h @@ -59,7 +59,11 @@ #endif // C23 related macros -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201904L) +#if defined(__cplusplus) && (__cplusplus >= 201703L) +#define WINPR_FALLTHROUGH \ + (void)0; \ + [[fallthrough]]; +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201904L) #define WINPR_FALLTHROUGH \ (void)0; \ [[fallthrough]];