Skip to content

Commit 5137f8b

Browse files
committed
stdlib: repair windows build
When building for a pure windows environment, we build against a newer CRT which does not provide direct access to __argc, __argv. They are hidden behind macros which use a function call. Use the header (stdlib) to get access to these rather than declaring them extern. This also makes the swift runtime more portable across various Windows environments. From stdlib.h in ucrt 10.0.10586.0: #ifdef _CRT_DECLARE_GLOBAL_VARIABLES_DIRECTLY extern int __argc; extern char** __argv; #else #define __argc (*__p___argc()) #define __argv (*__p___argv()) #endif The indirection is particularly nice on COFF where all module external variables are indirectly addressed.
1 parent 38362bb commit 5137f8b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

stdlib/public/stubs/CommandLine.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ extern "C" char ** _swift_stdlib_getUnsafeArgvArgc(int *outArgLen) {
9090
return outBuf;
9191
}
9292
#elif defined (_MSC_VER)
93-
extern int *__argc;
94-
extern char **__argv;
93+
#include <stdlib.h>
9594

9695
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
9796
extern "C" char ** _swift_stdlib_getUnsafeArgvArgc(int *outArgLen) {

0 commit comments

Comments
 (0)