From a912f8900cbbc8fc92d5e56eb0a954749fd76d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 26 Oct 2025 22:15:03 +0100 Subject: [PATCH] [PSDK] Improve the DECLSPEC_NOINITALL definition (#8438) Addendum to commit 73b54ce2a6. Conditionally define it on the `_MSC_VER >= 1915, and add the other `MIDL_PASS` and co. guard checks as in the official Windows PSDK. Additionally, no-op the define for Clang to silence the following warnings: ``` sdk\include\ddk\ntddk.h(2050,35): warning: __declspec attribute 'no_init_all' is not supported [-Wignored-attributes] sdk\include\psdk\ntdef.h(40,95): note: expanded from macro 'DECLSPEC_NOINITALL' ``` Granted, this may be due to the fact our GitHub actions currently use Clang 13.0.1: ``` -- The C compiler identification is Clang 13.0.1 with MSVC-like command-line -- The CXX compiler identification is Clang 13.0.1 with MSVC-like command-line ``` while support for `no_init_all` may have been added for Clang 22.0.0, if https://clang.llvm.org/docs/AttributeReference.html#no-init-all is correct. (See PR https://github.com/llvm/llvm-project/pull/116847 ) --- sdk/include/xdk/ntdef.template.h | 3 ++- sdk/include/xdk/winnt.template.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/include/xdk/ntdef.template.h b/sdk/include/xdk/ntdef.template.h index 0c1dd44e24a..45ed1b37d66 100644 --- a/sdk/include/xdk/ntdef.template.h +++ b/sdk/include/xdk/ntdef.template.h @@ -39,7 +39,8 @@ extern "C" { #endif #ifndef DECLSPEC_NOINITALL -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (!defined(__clang__) || (__clang_major__ >= 22)) && \ + (_MSC_VER >= 1915) && !defined(MIDL_PASS) && !defined(SORTPP_PASS) && !defined(RC_INVOKED) #define DECLSPEC_NOINITALL __pragma(warning(push)) __pragma(warning(disable:4845)) __declspec(no_init_all) __pragma(warning(pop)) #else #define DECLSPEC_NOINITALL diff --git a/sdk/include/xdk/winnt.template.h b/sdk/include/xdk/winnt.template.h index 82b7ec4fb49..d876a5f3094 100644 --- a/sdk/include/xdk/winnt.template.h +++ b/sdk/include/xdk/winnt.template.h @@ -57,7 +57,8 @@ #endif #ifndef DECLSPEC_NOINITALL -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (!defined(__clang__) || (__clang_major__ >= 22)) && \ + (_MSC_VER >= 1915) && !defined(MIDL_PASS) && !defined(SORTPP_PASS) && !defined(RC_INVOKED) #define DECLSPEC_NOINITALL __pragma(warning(push)) __pragma(warning(disable:4845)) __declspec(no_init_all) __pragma(warning(pop)) #else #define DECLSPEC_NOINITALL