Visual Studio 2010 error C2065: '_In_opt_z_' : undeclared identifier 编译错误

时间:2023-03-08 17:07:59

当用Visual Studio 2010 编译时 发生如下编译错误:

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(550): error C2065: '_In_opt_z_' : undeclared identifier

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(550): error C2143: syntax error : missing ')' before 'const'

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(550): warning C4229: anachronism used : modifiers on data are ignored

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(550): error C2182: '_invoke_watson' : illegal use of type 'void'

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(550): error C2495: '_invoke_watson' : '__declspec(noreturn)' can only be applied to function declarations or definitions

。。。

。。。

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(96): error C2144: syntax error : 'int' should be preceded by ')'

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(96): error C2448: 'isupper' : function-style initializer appears to be a function definition

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(96): error C2059: syntax error : ')'

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(97): error C2144: syntax error : 'int' should be preceded by ';'

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(97): error C2065: '_In_' : undeclared identifier

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(97): error C2144: syntax error : 'int' should be preceded by ')'

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(97): error C2448: '_isupper_l' : function-style initializer appears to be a function definition

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(97): error C2146: syntax error : missing ';' before identifier '_locale_t'

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(97): error C2059: syntax error : ')'

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(98): error C2144: syntax error : 'int' should be preceded by ';'

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(98): error C2065: '_In_' : undeclared identifier

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(98): error C2144: syntax error : 'int' should be preceded by ')'

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(98): error C2448: 'islower' : function-style initializer appears to be a function definition

2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(98): error C2059: syntax error : ')'

。。。

这是由于WDK中的sal.h文件和Visual Studio中的sal.h文件冲突了。

由于Visual Studio 2010中的sal.h文件比较新,因此产生了这个错误。

解决方法:

1.删除WDK中的sal.h

2.重命名WDK中的sal.h

3.把Visual Studio 2010中的sal.h copy到WDK目录中 覆盖WDK的sal.h

WDK sal.h的位置在:C:\WinDDK\7600.16385.0\inc\api\sal.h

4. 将C:\Program Files\Microsoft Visual Studio 10.0\VC\include;

放在它C:\WinDDK\7600.16385.1\inc\api前面,即可