Skip to content

Commit ea05fcc

Browse files
authored
Merge pull request #113 from libnativeapi/fix/windows-gdiplus-nominmax-issue-77
fix(windows): import std::min/std::max before gdiplus.h under NOMINMAX
2 parents a166a18 + f94fa0d commit ea05fcc

5 files changed

Lines changed: 28 additions & 5 deletions

File tree

‎src/platform/windows/clipboard_windows.cpp‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
#ifndef NOMINMAX
22
#define NOMINMAX
33
#endif
4+
// clang-format off
45
// Windows headers must precede GDI+ and shell declarations.
56
#include <windows.h>
6-
7+
#include <algorithm>
8+
// gdiplus.h spells min / max unqualified and breaks under NOMINMAX without these.
9+
using std::max;
10+
using std::min;
711
#include <gdiplus.h>
812
#include <shellapi.h>
913
#include <shlobj.h>
14+
// clang-format on
1015

11-
#include <algorithm>
1216
#include <climits>
1317
#include <cstdio>
1418
#include <cstring>

‎src/platform/windows/drag_source_windows.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
#include <ole2.h>
44
#include <shellapi.h>
55
#include <shlobj.h>
6-
// clang-format on
6+
#include <algorithm>
7+
// gdiplus.h spells min / max unqualified and breaks under NOMINMAX without these.
8+
using std::max;
9+
using std::min;
710
#include <gdiplus.h>
11+
// clang-format on
812

913
#include <memory>
1014
#include <string>

‎src/platform/windows/image_windows.cpp‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
// clang-format off
2+
#include <windows.h>
13
#include <comdef.h>
4+
#include <algorithm>
5+
// gdiplus.h spells min / max unqualified and breaks under NOMINMAX without these.
6+
using std::max;
7+
using std::min;
28
#include <gdiplus.h>
3-
#include <windows.h>
9+
// clang-format on
410
#include <memory>
511
#include <string>
612
#include <vector>

‎src/platform/windows/menu_winui3_windows.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
#include "winui3_runtime_windows.h"
44
#undef GetCurrentTime
55

6+
// clang-format off
7+
#include <algorithm>
8+
// gdiplus.h spells min / max unqualified and breaks under NOMINMAX without these.
9+
using std::max;
10+
using std::min;
611
#include <gdiplus.h>
12+
// clang-format on
713
#include <robuffer.h>
814
#include <winrt/Windows.Foundation.Collections.h>
915
#include <winrt/Windows.Storage.Streams.h>

‎src/platform/windows/window_taskbar_windows.cpp‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
#include <windows.h>
33
#include <commctrl.h>
44
#include <dwmapi.h>
5+
#include <algorithm>
6+
// gdiplus.h spells min / max unqualified and breaks under NOMINMAX without these.
7+
using std::max;
8+
using std::min;
59
#include <gdiplus.h>
610
#include <shobjidl.h>
711
// clang-format on
812

9-
#include <algorithm>
1013
#include <array>
1114
#include <chrono>
1215
#include <cmath>

0 commit comments

Comments
 (0)