编译错误:errorC2146的解决办法
最近在开发⼀个3D软件渲染器,渲染模块调⽤DDraw API实现。使⽤VC++ 2008。编译的时候出现下⾯的⼀连串错误:
1>c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(236) : error C2146: 语法错误 : 缺少“;”(在标识符“PVOID64”的前
⾯)
1>c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(236) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不
⽀持默认 int
1>c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7818) : error C2146: 语法错误 : 缺少“;”(在标识符“Buffer”的前⾯)
1>c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7818) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++
不⽀持默认 int
1>c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7818) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++
不⽀持默认 int
打开winnt.h头⽂件,定位到产⽣error C2146的第236⾏:
typedef void * POINTER_64 PVOID64;
初步断定,原因应该是编译器不认识POINTER_64。⽹上查了⼀下,原来是由于我的项⽬依赖的DirectX 8.1 SDK,其Include directory包含的BaseTsd.h是⼀个早期的版本,其中还没有定义POINTER_64。
html实现用户注册登录代码⽹上的解决办法:
This is indeed the problem. The DirectX Include directory contains an early version of BaseTsd.h which does not include the definition for POINTER_64. You should instead use the version of BaseTsd.h in the Platform SDK, either the one that ships with Visual Studio 2005 (C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\BaseTsd.h) or in an updated Microsoft SDK installation. In order to get the compiler to use the right file, just remove BaseTsd.h from the DirectX Include directory.
于是,我将DirectX 8.1 SDK的Include⽬录下的BaseTsd.h删掉,项⽬就顺利编译了。