Direct Show 应用程序某个编译错误的解决办法

新近编程要vc9 (Visual Studio 2008)用到usb摄像头,在编译direct show基础库的时候,遇到如下的错误提示:

:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(222) : error C2146: syntax error : missing ';' before identifier 'PVOID64'

C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(222) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(5940) : error C2146: syntax error : missing ';' before identifier 'Buffer'

C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(5940) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(5940) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

其中C4430好解决,这只是vc6向vc9移植时的一般问题。比较难办的是c2146.

有一种办法是说调整编译器配置选项中的头文件顺序,如

Before I have (he don't works)
C:\DXSDK\Include
$(VCInstallDir)include
$(VCInstallDir)atlmfc\include
$(VCInstallDir)PlatformSDK\include
$(FrameworkSDKDir)include
Now i solve the problem with the order of directx SDK
$(VCInstallDir)include
$(VCInstallDir)atlmfc\include
$(VCInstallDir)PlatformSDK\include
$(FrameworkSDKDir)include
C:\DXSDK\Include
good luck

但上面的办法在某些项目中解决不了,比如dshow自动的示例。下面给出产生这个问题的原因和解决办法。

原因:

DirectX Include目录下面包含了一个叫BaseTsd.h的过期的头文件,它并没有定义类型 ,我们可以命名用Platform SDK的头文件来代替它。

解决办法:

非常简单,把 DirectX Include中的BaseTsd.h删除即可。这样做的优点是,不用再来回调整头文件的顺序了。

你可能感兴趣的:(C++,c,Microsoft,C#,vc++)