Skip to content

Commit 5927527

Browse files
committed
Switch order of _WIN64/_WIN32 checks in computation of C types for Int/UInt
64-bit Windows defines both _WIN64 and _WIN32, so the logic here would always end up defining 32-bit C types for Swift's `Int` and `UInt`. Fix the ordering to check for 64-bit first, then 32-bit second. Note that the SwiftShims version of this code has always been wrong, but it's completely benign because SwiftShims is only used in the Swift runtime itself, which is built with Clang (on all platforms), and doesn't need to go through this code path. Still, we fix it in both places, so we don't get a nasty surprise if the SwiftShims version of the header later gets included in a non-Clang C++ compiler.
1 parent e023274 commit 5927527

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

include/swift/Basic/CBasicBridging.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ typedef unsigned __INT32_TYPE__ __swiftc_uint32_t;
6464
#define __swiftc_uintn_t(n) __swiftc_join3(__swiftc_uint, n, _t)
6565

6666
#if defined(_MSC_VER) && !defined(__clang__)
67-
#if defined(_WIN32)
68-
typedef __swiftc_int32_t SwiftInt;
69-
typedef __swiftc_uint32_t SwiftUInt;
70-
#elif defined(_WIN64)
67+
#if defined(_WIN64)
7168
typedef __swiftc_int64_t SwiftInt;
7269
typedef __swiftc_uint64_t SwiftUInt;
70+
#elif defined(_WIN32)
71+
typedef __swiftc_int32_t SwiftInt;
72+
typedef __swiftc_uint32_t SwiftUInt;
7373
#else
7474
#error unknown windows pointer width
7575
#endif

stdlib/public/SwiftShims/swift/shims/SwiftStdint.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ typedef unsigned __INT8_TYPE__ __swift_uint8_t;
7171
#define __swift_uintn_t(n) __swift_join3(__swift_uint, n, _t)
7272

7373
#if defined(_MSC_VER) && !defined(__clang__)
74-
#if defined(_WIN32)
75-
typedef __swift_int32_t __swift_intptr_t;
76-
typedef __swift_uint32_t __swift_uintptr_t;
77-
#elif defined(_WIN64)
74+
#if defined(_WIN64)
7875
typedef __swift_int64_t __swift_intptr_t;
7976
typedef __swift_uint64_t __swift_uintptr_t;
77+
#elif defined(_WIN32)
78+
typedef __swift_int32_t __swift_intptr_t;
79+
typedef __swift_uint32_t __swift_uintptr_t;
8080
#else
8181
#error unknown windows pointer width
8282
#endif

0 commit comments

Comments
 (0)