Issues / #3093
#3093 hc_persist_parity.cpp calls POSIX setenv/unsetenv: target does not build with MSVC, ctest reports 2 tests Not Run
open · @gputier · 0 comments · View on GitHub
NVIDIA / CUDAModels & quantsWindows
Description
## Context
On `main` at 477ac13c (2026-10-16), tag v0.1.45, the Windows build (Release, CUDA 13.4, sm_120, RTX 5090) fails to compile `src/kernels/hc_persist_parity.cpp` with MSVC. Lines 55-56:
```cpp
if (off) unsetenv("STRATA_HC_PERSIST"); else setenv("STRATA_HC_PERSIST", "1", 1);
```
`setenv` and `unsetenv` are POSIX functions. MSVC does not declare them. The compiler reports:
```
hc_persist_parity.cpp(55): error C3861: 'unsetenv': identifier not found
hc_persist_parity.cpp(56): error C3861: 'setenv': identifier not found
```
## Consequence
The `hc_persist_parity` target does not build on Windows. ctest marks `hc_persist_parity` and `hc_persist_default_off` as "Not Run" (CMakeLists.txt lines 1115-1119). The engine itself is not affected, since `STRATA_HC_PERSIST` is off by default. The test was added by cea3d61b, after 0.1.42.
## Proposed fix
The repository already handles this case elsewhere. `set_env` in `src/kernels/decode_cluster_parity.cpp` lines 46-52 calls `_putenv_s(name, value)` under `_WIN32` and `setenv(name, value, 1)` on other platforms. The same guard applies here. On Windows, `_putenv_s` with an empty value removes the variable (documented behavior), so the `--off` case maps to it:
```cpp
#ifdef _WIN32
if (off) _putenv_s("STRATA_HC_PERSIST", "");
else _putenv_s("STRATA_HC_PERSIST", "1");
#else
if (off) unsetenv("STRATA_HC_PERSIST");
else setenv("STRATA_HC_PERSIST", "1", 1);
#endif
```
Related on this site
Quick links to related pages.