Skip to content

Commit

Permalink
Include windows.h before other Win32 header files
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Jan 28, 2025
1 parent b1eb3b1 commit cd975c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/asm/lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <windows.h> // target architecture
// clang-format on
#include <fileapi.h> // CreateFileA
#include <winbase.h> // CreateFileMappingA
#include <memoryapi.h> // MapViewOfFile
#include <handleapi.h> // CloseHandle
// clang-format on
#include <memoryapi.h> // MapViewOfFile
#include <winbase.h> // CreateFileMappingA

static char *mapFile(int fd, std::string const &path, size_t) {
void *mappingAddr = nullptr;
Expand Down
7 changes: 5 additions & 2 deletions test/gfx/rgbgfx_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@
#include <spawn.h>
#include <unistd.h>
#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 <windows.h>
// clang-format on
#include <errhandlingapi.h>
#include <processthreadsapi.h>
#include <windows.h>

#undef max // This macro conflicts with `std::numeric_limits<...>::max()`
#endif

Expand Down

0 comments on commit cd975c7

Please sign in to comment.