Skip to content

Commit 625476d

Browse files
committed
fix(core): guard _dupenv_s with _MSC_VER rather than _WIN32
_dupenv_s is an MSVC CRT extension. MinGW-w64 targets Windows, so it satisfies defined(_WIN32) and selects a branch it cannot link: a CNA D3D11 or D3D12 cross-build fails with "undefined reference to `__imp__dupenv_s'", and with it no Windows cross-build of CnaTests links at all. getenv is the correct fallback for that toolchain and is already what the non-Windows branch uses.
1 parent bc8dbf4 commit 625476d

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

modules/core/src/System/Environment.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ namespace {
7474
// getenv("") is unspecified by POSIX. Real .NET returns null for an empty name, which
7575
// this runtime represents as an unsuccessful lookup and an empty public return value.
7676
if (name.empty()) return false;
77-
#if defined(_WIN32)
77+
// _dupenv_s is an MSVC CRT extension. MinGW-w64 targets Windows but does not export it, so
78+
// `defined(_WIN32)` selects a branch that cannot link there -- a CNA D3D11 cross-build fails with
79+
// "undefined reference to `__imp__dupenv_s'". getenv is the correct fallback for that toolchain.
80+
#if defined(_MSC_VER)
7881
char* rawValue = nullptr;
7982
std::size_t valueLength = 0;
8083
if (_dupenv_s(&rawValue, &valueLength, name.c_str()) != 0 || rawValue == nullptr) {

0 commit comments

Comments
 (0)