From 01c9106b599c285173295baa290458d757dc5fbb Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Mon, 27 Jan 2025 19:17:27 -0500 Subject: [PATCH] Include `windows.h` before other Win32 header files --- src/asm/lexer.cpp | 13 ++++++------- test/gfx/rgbgfx_test.cpp | 5 ++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/asm/lexer.cpp b/src/asm/lexer.cpp index 5fce6111..04196875 100644 --- a/src/asm/lexer.cpp +++ b/src/asm/lexer.cpp @@ -35,15 +35,14 @@ // Neither MSVC nor MinGW provide `mmap` #if defined(_MSC_VER) || defined(__MINGW32__) -// clang-format off - // (we need these `include`s in this order) - #define WIN32_LEAN_AND_MEAN // include less from windows.h +// clang-format off: maintain `include` order + #define WIN32_LEAN_AND_MEAN // Include less from `windows.h` #include // target architecture - #include // CreateFileA - #include // CreateFileMappingA - #include // MapViewOfFile - #include // CloseHandle // clang-format on + #include // CreateFileA + #include // CloseHandle + #include // MapViewOfFile + #include // CreateFileMappingA static char *mapFile(int fd, std::string const &path, size_t) { void *mappingAddr = nullptr; diff --git a/test/gfx/rgbgfx_test.cpp b/test/gfx/rgbgfx_test.cpp index 59578922..d394464e 100644 --- a/test/gfx/rgbgfx_test.cpp +++ b/test/gfx/rgbgfx_test.cpp @@ -27,10 +27,13 @@ #include #include #else - #define WIN32_LEAN_AND_MEAN // Include less from `windows.h` to avoid conflicts +// clang-format off: maintain `include` order + #define WIN32_LEAN_AND_MEAN // Include less from `windows.h` #include +// clang-format on #include #include + #undef max // This macro conflicts with `std::numeric_limits<...>::max()` #endif