【问题标题】:getenv in Visual C++ 2012Visual C++ 2012 中的 getenv
【发布时间】:2013-05-14 19:08:25
【问题描述】:

我想在 Visual Studio 2012 的 C++ 项目中使用 C 中的 getenv 函数。

代码:

extern "C" System::SByte^ getenv(const System::SByte^ name);

然后在某个函数中:

String^ h1 = "HOMEDRIVE";
const System::SByte^ c1 = dynamic_cast<const System::SByte^>(h1);
getenv(c1);

我得到的错误:

Error   11  error LNK2019: unresolved external symbol "extern "C" class System::SByte ^ __clrcall getenv(class System::SByte const ^)" (?getenv@@$$J0YMP$AAVSByte@System@@P$ABV12@@Z) referenced in function "public: void __clrcall Kameleon::Form1::createConfig(void)" (?createConfig@Form1@Kameleon@@$$FQ$AAMXXZ)   C:\Users\Michal\Desktop\Kameleon\Kameleon\Kameleon\Kameleon.obj Kameleon

【问题讨论】:

标签: c++ c visual-studio-2012 extern getenv


【解决方案1】:

我认为对于 C++ 项目,您可以使用 getenv from &lt;cstdlib&gt;,而不是 C++/CLI 之一。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-14
    • 2023-04-03
    • 2011-11-17
    • 2015-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多