2009-07-23 70 views

回答

3

當使用/ MD(或變體),符號_environ_wenviron通過函數調用置換。您需要追蹤使用這些(過時的和棄用的)符號的代碼,並使它們成爲use the proper function names。我在google也發現了很多與你同樣問題的人。

我發現了一些更詳細here

Polling _environ in a Unicode context is meaningless when /MD or /MDd linkage is used. For the CRT DLL, the type (wide or multibyte) of the program is unknown. Only the multibyte type is created because that is the most likely scenario.

如果改變用途的符號_environ的寬字符版本_wenviron,你原來的代碼可能會工作。

+1

好的,所以我需要使用getenv_s,_wgetenv_s和_putenv_s,_wputenv_s。但是如果我想迭代所有的環境變量呢? – dimba 2009-07-23 09:46:28

1

正如documentation所述,_environ在Stdlib.h中聲明並在crt lib中實現。

因此,您可能在與此庫鏈接時遇到問題,或者它可能會拾取錯誤的lib(嘗試檢查構建路徑)。

相關問題