gpt4 book ai didi

c++ - 无法在 Visual C++ ATL 项目中使用系统命名空间

转载 作者:太空宇宙 更新时间:2023-11-04 11:45:41 24 4
gpt4 key购买 nike

我有一个 ATL 项目,我必须在其中使用系统命名空间来设置环境变量。我试过:

#using <mscorlib.dll>
using namespace System;

在我的 dllmain.cpp 文件中。

在构建时,我得到了:

fatal error C1190: managed targeted code requires a '/clr' option even after adding /clr option project->properties->common language runtime support.

如果我删除#using mscorlib.dll,我会得到:

error C2871: 'System' : a namespace with this name does not exist

如何在我的 ATL 项目中使用这个命名空间?

最佳答案

参见 this link来自 MSDN。

我在这里引用答案:

As you are including a reference to mscorlib.dll you need to let thecompiler know that you are targetting the .NET Runtime. The compilerswitch that controls this is /clr - hence the error message you areseeing. To enable this option from the project system in the SolutionExplorer pane right-click on your project, select ConfigurationProperties.General and then select "Common Language Runtime support"and from the drop-down list select "Common Language Runtime Support(/clr)".

In C++ identifiers are case-sensitive: I suspect that the name shouldbe System::Console.

关于c++ - 无法在 Visual C++ ATL 项目中使用系统命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19947224/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com