fixes #19292; fixes #21122; fixes putEnv and setEnv with vcc (#21143)

* fixes #19292; fixes 21122; fixes putEnv and setEnv with vcc

* add a test
This commit is contained in:
ringabout 2022-12-21 03:26:32 +08:00 • committed by GitHub
commit 0aec095b26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 15 deletions

View file

@ -63,9 +63,13 @@ when not defined(nimscript):
import winlean
when defined(nimPreviewSlimSystem):
import std/widestrs
proc c_wgetenv(varname: WideCString): WideCString {.importc: "_wgetenv",
type wchar_t {.importc: "wchar_t", header: "<stdlib.h>".} = int16
proc c_wgetenv(varname: ptr wchar_t): ptr wchar_t {.importc: "_wgetenv",
header: "<stdlib.h>".}
proc getEnvImpl(env: cstring): WideCString = c_wgetenv(env.newWideCString)
proc getEnvImpl(env: cstring): WideCString =
let r: WideCString = env.newWideCString
cast[WideCString](c_wgetenv(cast[ptr wchar_t](r)))
else:
proc c_getenv(env: cstring): cstring {.
importc: "getenv", header: "<stdlib.h>".}