You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR addresses two problems related to Windows macro conflicts:
max/min definition
Changed the check from if(MSVC) to if(WIN32) when defining NOMINMAX. This ensures that the min/max macros from <windows.h> are masked on all Windows compilers (MSVC, clang-cl, MinGW).
#ifdef checks in source
Replaced #if WIN32 with #ifdef WIN32 to ensure correct macro detection. This avoids potential compilation errors when building with Clang + MSVC, where undefined macros could cause preprocessing issues.
Under what circumstances do you encounter that problem? I don't see any issues on Win11.
Compiler
Clang 22.1 + MSVC 18.3.2
System
Windows 11 Pro 22H2
Windows SDK 10.0.26100.0
Errors
[build] C:/Data/repos/samples_vk/framework\common/helpers.h:205:96: error: too few arguments provided to function-like macro invocation
[build] 205 | if (static_cast<uintmax_t>(value) > static_cast<uintmax_t>(std::numeric_limits<uint32_t>::max()))
[build] | ^
[build] C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared\minwindef.h:193:9: note: macro 'max' defined here
[build] 193 | #define max(a,b) (((a) > (b)) ? (a) : (b))
[build] | ^
[build] In file included from C:/Data/repos/samples_vk/framework/core/debug.cpp:20:
[build] In file included from C:/Data/repos/samples_vk/framework\core/command_buffer.h:22:
[build] In file included from C:/Data/repos/samples_vk/framework\core/device.h:22:
[build] In file included from C:/Data/repos/samples_vk/framework\core/buffer.h:23:
[build] In file included from C:/Data/repos/samples_vk/framework\core/allocated.h:23:
[build] In file included from C:/Data/repos/samples_vk/framework\core/physical_device.h:21:
[build] In file included from C:/Data/repos/samples_vk/framework\core/instance.h:21:
[build] C:/Data/repos/samples_vk/framework\common/helpers.h:205:38: error: static_cast from 'unsigned int (*)() noexcept' to 'uintmax_t' (aka 'unsigned long long') is not allowed
[build] 205 | if (static_cast<uintmax_t>(value) > static_cast<uintmax_t>(std::numeric_limits<uint32_t>::max()))
[build] | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] In file included from C:/Data/repos/samples_vk/framework/core/debug.cpp:20:
[build] In file included from C:/Data/repos/samples_vk/framework\core/command_buffer.h:22:
[build] In file included from C:/Data/repos/samples_vk/framework\core/device.h:25:
[build] In file included from C:/Data/repos/samples_vk/framework\hpp_fence_pool.h:20:
[build] C:/Data/repos/samples_vk/framework\fence_pool.h:48:70: error: too few arguments provided to function-like macro invocation
[build] 48 | VkResult wait(uint64_t timeout = std::numeric_limits<uint64_t>::max()) const;
[build] | ^
[build] C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared\minwindef.h:193:9: note: macro 'max' defined here
[build] 193 | #define max(a,b) (((a) > (b)) ? (a) : (b))
[build] | ^
[build] In file included from C:/Data/repos/samples_vk/framework/core/debug.cpp:20:
[build] In file included from C:/Data/repos/samples_vk/framework\core/command_buffer.h:22:
[build] In file included from C:/Data/repos/samples_vk/framework\core/device.h:25:
[build] In file included from C:/Data/repos/samples_vk/framework\hpp_fence_pool.h:20:
[build] C:/Data/repos/samples_vk/framework\fence_pool.h:48:25: error: cannot initialize a parameter of type 'uint64_t' (aka 'unsigned long long') with an lvalue of type 'unsigned long long () noexcept'
[build] 48 | VkResult wait(uint64_t timeout = std::numeric_limits<uint64_t>::max()) const;
[build] | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] C:/Data/repos/samples_vk/framework\fence_pool.h:48:25: note: passing argument to parameter 'timeout' here
[build] In file included from C:/Data/repos/samples_vk/framework/core/debug.cpp:20:
[build] In file included from C:/Data/repos/samples_vk/framework\core/command_buffer.h:32:
[build] In file included from C:/Data/repos/samples_vk/framework\rendering/subpass.h:21:
[build] C:/Data/repos/samples_vk/framework\buffer_pool.h:349:65: error: expected unqualified-id
[build] 349 | vk::DeviceSize new_block_size = minimal ? minimum_size : std::max(block_size, minimum_size);
[build] | ^
[build] C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared\minwindef.h:193:29: note: expanded from macro 'max'
[build] 193 | #define max(a,b) (((a) > (b)) ? (a) : (b))
[build] | ^
[build] 5 errors generated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses two problems related to Windows macro conflicts:
max/min definition
Changed the check from
if(MSVC)toif(WIN32)when defining NOMINMAX. This ensures that the min/max macros from <windows.h> are masked on all Windows compilers (MSVC, clang-cl, MinGW).#ifdef checks in source
Replaced
#if WIN32with#ifdef WIN32to ensure correct macro detection. This avoids potential compilation errors when building with Clang + MSVC, where undefined macros could cause preprocessing issues.General Checklist:
Please ensure the following points are checked:
[ ] I have commented any added functions (in line with Doxygen)[ ] I have commented any code that could be hard to understandNote: The Samples CI runs a number of checks including:
[ ] I have updated the header Copyright to reflect the current year (CI build will fail if Copyright is out of date)