From f94fa0d0110165b64a98c23b9866b3c0a0ee1f12 Mon Sep 17 00:00:00 2001 From: LiJianying Date: Wed, 2 Dec 2026 21:31:30 +0800 Subject: [PATCH] fix(windows): import std::min/std::max before gdiplus.h under NOMINMAX --- src/platform/windows/clipboard_windows.cpp | 8 ++++++-- src/platform/windows/drag_source_windows.cpp | 6 +++++- src/platform/windows/image_windows.cpp | 8 +++++++- src/platform/windows/menu_winui3_windows.cpp | 6 ++++++ src/platform/windows/window_taskbar_windows.cpp | 5 ++++- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/platform/windows/clipboard_windows.cpp b/src/platform/windows/clipboard_windows.cpp index bdf1187f..de4fedb2 100644 --- a/src/platform/windows/clipboard_windows.cpp +++ b/src/platform/windows/clipboard_windows.cpp @@ -1,14 +1,18 @@ #ifndef NOMINMAX #define NOMINMAX #endif +// clang-format off // Windows headers must precede GDI+ and shell declarations. #include - +#include +// gdiplus.h spells min / max unqualified and breaks under NOMINMAX without these. +using std::max; +using std::min; #include #include #include +// clang-format on -#include #include #include #include diff --git a/src/platform/windows/drag_source_windows.cpp b/src/platform/windows/drag_source_windows.cpp index c8fe71f0..f28d7a6f 100644 --- a/src/platform/windows/drag_source_windows.cpp +++ b/src/platform/windows/drag_source_windows.cpp @@ -3,8 +3,12 @@ #include #include #include -// clang-format on +#include +// gdiplus.h spells min / max unqualified and breaks under NOMINMAX without these. +using std::max; +using std::min; #include +// clang-format on #include #include diff --git a/src/platform/windows/image_windows.cpp b/src/platform/windows/image_windows.cpp index 0c681f79..bf133fa1 100644 --- a/src/platform/windows/image_windows.cpp +++ b/src/platform/windows/image_windows.cpp @@ -1,6 +1,12 @@ +// clang-format off +#include #include +#include +// gdiplus.h spells min / max unqualified and breaks under NOMINMAX without these. +using std::max; +using std::min; #include -#include +// clang-format on #include #include #include diff --git a/src/platform/windows/menu_winui3_windows.cpp b/src/platform/windows/menu_winui3_windows.cpp index 2f635e1d..f4d5cc09 100644 --- a/src/platform/windows/menu_winui3_windows.cpp +++ b/src/platform/windows/menu_winui3_windows.cpp @@ -3,7 +3,13 @@ #include "winui3_runtime_windows.h" #undef GetCurrentTime +// clang-format off +#include +// gdiplus.h spells min / max unqualified and breaks under NOMINMAX without these. +using std::max; +using std::min; #include +// clang-format on #include #include #include diff --git a/src/platform/windows/window_taskbar_windows.cpp b/src/platform/windows/window_taskbar_windows.cpp index fbfbbed0..b77327ac 100644 --- a/src/platform/windows/window_taskbar_windows.cpp +++ b/src/platform/windows/window_taskbar_windows.cpp @@ -2,11 +2,14 @@ #include #include #include +#include +// gdiplus.h spells min / max unqualified and breaks under NOMINMAX without these. +using std::max; +using std::min; #include #include // clang-format on -#include #include #include #include