File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -122,9 +122,19 @@ OnceToken_t swift::runtime::environment::initializeToken;
122122extern " C" char **environ;
123123#define ENVIRON environ
124124#elif defined(_WIN32)
125+ // `_environ` is DLL-imported unless we are linking against the static C runtime
126+ // (via `/MT` or `/MTd`).
127+ #if defined(_DLL)
128+ extern " C" __declspec(dllimport) char **_environ;
129+ #else
125130extern " C" char **_environ;
131+ #endif
132+ // `_environ` is unavailable in the Windows Runtime environment.
133+ // https://docs.microsoft.com/en-us/cpp/c-runtime-library/environ-wenviron?view=msvc-160
134+ #if !defined(_WINRT_DLL)
126135#define ENVIRON _environ
127136#endif
137+ #endif
128138
129139#ifdef ENVIRON
130140void swift::runtime::environment::initialize (void *context) {
You can’t perform that action at this time.
0 commit comments