在VS2008中,单独使用“winnt.h”头文件时会出现奇奇怪怪的编译问题

  

1 #include <winnt.h>
2
3 int main()
4 {
5 return 0;
6 }

对以上代码进行编译时会出现错误:

1>c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(296) : error C2146: 语法错误 : 缺少“;”(在标识符“WCHAR”的前面)
1>c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(296) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(299) : error C2143: 语法错误 : 缺少“;”(在“*”的前面)
1>c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(299) : error C2040: “PWSTR”: “CONST”与“WCHAR *”的间接寻址级别不同
1>c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(299) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int

....

在网上的解决方案大多都是通过“工具”——>“选项”——>“项目和解决方案”——>“VC++目录”来修改“包含文件”中DX SDK的路径,将其移动到最后。

但是在我这里并没有关于DX SDK的路径。

所以为了寻找另一种解决方法花费了N多时间......而这种解决也非常的简单,只要将“windows.h”放在“winnt.h”前面一起使用就可以了。这个点子来源于:http://zhidao.baidu.com/question/166953709.html

1 #include <windows.h>
2 #include <winnt.h>
3
4 int main()
5 {
6 return 0;
7 }



相关文章:

  • 2022-12-23
  • 2021-07-14
  • 2021-08-22
  • 2022-03-03
  • 2021-10-05
  • 2022-12-23
猜你喜欢
  • 2022-01-31
  • 2022-12-23
  • 2021-11-20
  • 2021-09-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案