Skip to content

Commit e0b24e9

Browse files
authored
Merge pull request #58401 from apple/jgrynspan/windows-warning-fixes
Fix some build issues on Windows
2 parents 58a2ed1 + 7b630b3 commit e0b24e9

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

stdlib/public/CommandLineSupport/CommandLine.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,25 +124,27 @@ char **_swift_stdlib_getUnsafeArgvArgc(int *outArgLen) {
124124
if (szBufferSize == 0) {
125125
swift::fatalError(0,
126126
"Fatal error: Could not retrieve commandline "
127-
"arguments: %u\n",
128-
GetLastError());
127+
"argument %d: %lu\n",
128+
i, GetLastError());
129129
return nullptr;
130130
}
131131

132132
char *buffer = static_cast<char *>(
133133
calloc(static_cast<size_t>(szBufferSize), sizeof(char)));
134134
if (buffer == nullptr) {
135135
swift::fatalError(0,
136-
"Fatal error: Could not allocate space for commandline"
137-
"arguments");
136+
"Fatal error: Could not allocate space for commandline "
137+
"argument %d: %d\n",
138+
i, errno);
138139
return nullptr;
139140
}
140141

141142
if (!WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, szArgList[i], -1,
142143
buffer, szBufferSize, nullptr, nullptr)) {
143144
swift::fatalError(0,
144145
"Fatal error: Conversion to UTF-8 failed for "
145-
"commandline arguments");
146+
"commandline argument %d: %lu\n",
147+
i, GetLastError());
146148
return nullptr;
147149
}
148150

stdlib/public/Concurrency/Task.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,23 +1265,21 @@ static void swift_task_asyncMainDrainQueueImpl() {
12651265
"swift_task_asyncMainDrainQueue");
12661266
#else
12671267
#if defined(_WIN32)
1268-
static void(FAR *pfndispatch_main)(void) = NULL;
1269-
1270-
if (pfndispatch_main)
1271-
return pfndispatch_main();
1272-
12731268
HMODULE hModule = LoadLibraryW(L"dispatch.dll");
1274-
if (hModule == NULL)
1275-
swift_reportError(0, "unable to load dispatch.dll");
1269+
if (hModule == NULL) {
1270+
swift_Concurrency_fatalError(0,
1271+
"unable to load dispatch.dll: %lu", GetLastError());
1272+
}
12761273

1277-
pfndispatch_main =
1278-
reinterpret_cast<void (FAR *)(void)>(GetProcAddress(hModule,
1279-
"dispatch_main"));
1280-
if (pfndispatch_main == NULL)
1281-
swift_reportError(0, "unable to locate dispatch_main in dispatch.dll");
1274+
auto pfndispatch_main = reinterpret_cast<void (FAR *)(void)>(
1275+
GetProcAddress(hModule, "dispatch_main"));
1276+
if (pfndispatch_main == NULL) {
1277+
swift_Concurrency_fatalError(0,
1278+
"unable to locate dispatch_main in dispatch.dll: %lu", GetLastError());
1279+
}
12821280

12831281
pfndispatch_main();
1284-
exit(0);
1282+
swift_unreachable("Returned from dispatch_main()");
12851283
#else
12861284
// CFRunLoop is not available on non-Darwin targets. Foundation has an
12871285
// implementation, but CoreFoundation is not meant to be exposed. We can only

stdlib/public/stubs/Random.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void swift_stdlib_random(void *buf, __swift_size_t nbytes) {
7070
static_cast<ULONG>(nbytes),
7171
BCRYPT_USE_SYSTEM_PREFERRED_RNG);
7272
if (!BCRYPT_SUCCESS(status)) {
73-
fatalError(0, "Fatal error: 0x%.8X in '%s'\n", status, __func__);
73+
fatalError(0, "Fatal error: 0x%lX in '%s'\n", status, __func__);
7474
}
7575
}
7676

0 commit comments

Comments
 (0)