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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6811736/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 20:42:37  来源:igfitidea点击:

Including a .idl file in a C++ project

c++visual-studio-2010directshowidl

提问by wyatt

I'm building a project in C++ which uses DirectShow's video capture library to connect to a camera. The video card manufacturer (BlackMagic) has provided .idl (Interface Definition Language) files which add new capture graphs to the standard collection.

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

Thing is, I've never come across a .idl file, and the very vague "include the file" direction doesn't help much. Including it with a #include directive doesn't throw up any errors, but the program also fails to pull in the various definitions which I presume it's intended to add, since it's the only file I'm told to include with the project.

事实是,我从来没有遇到过 .idl 文件,而且非常模糊的“包含文件”方向也无济于事。将它与 #include 指令一起包含不会引发任何错误,但该程序也无法引入我认为它打算添加的各种定义,因为它是我被告知要包含在项目中的唯一文件。

My question is: how should one include a .idl file in a project?

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

回答by Sasha

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.

Observation: the steps are described for VS2008 but I don't think VS2010 is different in that perspective.

观察:这些步骤是针对 VS2008 描述的,但我认为 VS2010 从这个角度来看并没有什么不同。