在C++项目中包含.idl文件

wya*_*att 14 c++ directshow idl visual-studio-2010

我正在用C++构建一个项目,该项目使用DirectShow的视频捕获库连接到摄像机.视频卡制造商(BlackMagic)提供了.idl(接口定义语言)文件,该文件将新的捕获图形添加到标准集合中.

事实上,我从未遇到过.idl文件,而且非常模糊的"包含文件"方向并没有多大帮助.用#include指令包含它不会引起任何错误,但程序也无法引入我想要添加的各种定义,因为它是我被告知包含在项目中的唯一文件.

我的问题是:如何在项目中包含.idl文件?

Sas*_*sha 19

For example: you have an AFileName.idl
1. Add the AFileName.idl to you project: Right Click on The project->Add->Existing Item...
2. Click Right on The AFileName.idl from the project->Compile
3. The step 2 will generate AFileName_h.h, AFileName_i.c, AFileName_p.c,...
4. Now you can #include "AFileName_h.h" and use it, you also may need 
   to add AFileName_i.c or other generated files to your project  
   depending on your needs.

观察:VS2008描述了这些步骤,但我不认为VS2010在这方面有所不同.

  • 如果你确实在项目中添加了.c文件,你可能还需要更改文件的C/C++ | 高级| "编译为"属性为"编译为C代码(/ TC)",可能还需要设置文件的C/C++ | 预编译标题| "预编译头"属性为"不使用预编译头" (5认同)