Skip to content

Commit 3286a44

Browse files
committed
[Runtime][Windows] A couple of files need to include <windows.h>
We shouldn't include <windows.h> implicitly from .cpp files, but should do it directly so that we know it's there. Also, if we're including <windows.h>, do it at the top of the file. rdar://90776105
1 parent 4b02784 commit 3286a44

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

lib/Threading/Win32.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
#if SWIFT_THREADING_WIN32
1818

19+
#define WIN32_LEAN_AND_MEAN
20+
#define NOMINMAX
21+
#include <windows.h>
22+
1923
#include "swift/Threading/Errors.h"
2024
#include "swift/Threading/Impl/Win32.h"
2125

stdlib/public/Concurrency/TaskPrivate.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
#ifndef SWIFT_CONCURRENCY_TASKPRIVATE_H
1818
#define SWIFT_CONCURRENCY_TASKPRIVATE_H
1919

20+
#if defined(_WIN32)
21+
#define WIN32_LEAN_AND_MEAN
22+
#define VC_EXTRA_LEAN
23+
#define NOMINMAX
24+
#include <Windows.h>
25+
#endif
26+
2027
#include "Error.h"
2128
#include "Tracing.h"
2229
#include "swift/ABI/Metadata.h"
@@ -36,12 +43,6 @@
3643
#if HAVE_PTHREAD_H
3744
#include <pthread.h>
3845
#endif
39-
#if defined(_WIN32)
40-
#define WIN32_LEAN_AND_MEAN
41-
#define VC_EXTRA_LEAN
42-
#define NOMINMAX
43-
#include <Windows.h>
44-
#endif
4546

4647
namespace swift {
4748

stdlib/public/runtime/Errors.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
//===----------------------------------------------------------------------===//
1616

1717
#if defined(_WIN32)
18+
#define WIN32_LEAN_AND_MEAN
19+
#define NOMINMAX
20+
#include <windows.h>
21+
1822
#include <mutex>
1923
#endif
2024

stdlib/public/runtime/Metadata.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
//
1515
//===----------------------------------------------------------------------===//
1616

17+
#if defined(_WIN32)
18+
#define WIN32_LEAN_AND_MEAN
19+
// Avoid defining macro max(), min() which conflict with std::max(), std::min()
20+
#define NOMINMAX
21+
#include <windows.h>
22+
#endif
23+
1724
#include "swift/Runtime/Metadata.h"
1825
#include "MetadataCache.h"
1926
#include "swift/Basic/Lazy.h"
@@ -37,12 +44,6 @@
3744
#include <new>
3845
#include <unordered_set>
3946
#include <vector>
40-
#if defined(_WIN32)
41-
#define WIN32_LEAN_AND_MEAN
42-
// Avoid defining macro max(), min() which conflict with std::max(), std::min()
43-
#define NOMINMAX
44-
#include <windows.h>
45-
#endif
4647
#if SWIFT_PTRAUTH
4748
#include <ptrauth.h>
4849
#endif

0 commit comments

Comments
 (0)