我刚刚从微软网站安装了 VS2010 Beta 1,我启动了一个基本的 C++ Win32 控制台应用程序,它生成了以下代码:
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
我尝试编译代码只是为了看看它是如何运行的,然后我遇到了几个(超过 100 个)编译错误。
这是构建输出的第一部分:
1>ClCompile:
1> stdafx.cpp
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(520): error C2065: '_In_opt_z_' : undeclared identifier
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(520): error C2143: syntax error : missing ')' before 'const'
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(520): warning C4229: anachronism used : modifiers on data are ignored
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(520): error C2182: '_invalid_parameter' : illegal use of type 'void'
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(520): error C2491: '_invalid_parameter' : definition of dllimport data not allowed
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(520): error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(527): error C2065: '_In_opt_z_' : undeclared identifier
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(527): error C2143: syntax error : missing ')' before 'const'
1>c:\program files\microsoft visual studio 10.0\vc\include\crtdefs.h(527): warning C4229: anachronism used : modifiers on data are ignored
pastebin完整列表
我认为可能包含文件被我之前安装的其他编译器版本(我也有 VS 2008)弄混了,所以我重新安装了 VS2010 只是为了覆盖标题,但这并没有多大作用。
提前感谢您提供的任何帮助,因为我很无助
最佳答案
问题出在: C:\WinDDK\6001.18001\inc\api\sal.h
sal.h 定义了在 CRT 头文件中使用的注释... DDK 包含自己的sal.h,该文件已过时且不包含所有注释。
有两种可能的解决方案: - 更改包含路径,使“C:\Program Files\Microsoft Visual Studio 10.0\VC\include”位于“C:\WinDDK\6001.18001\inc\api”之前
- 只需删除 "C:\WinDDK\6001.18001\inc\api\sal.h":)
关于c++ - VS2010 Beta 1 上的基本 C++ 应用程序出现多个编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1356653/