更改IDL生成的头文件
我正在开发一个旧版 c++ COM 项目,并将其转移到 Visual Studio 2010。在该项目的 IDL 文件中,我必须引用另一个 c++ 项目中的 ODL 文件。我的问题是另一个项目生成其头文件为 $(filename)_h.h。当我的 IDL 文件生成其头文件时,它会生成 ODL 文件名 $filename.h,并且无法引用正确的文件。
换句话说,在我的 IDL 文件(“MyIDLFile.idl”)中,我有一个类似于
import“MyODLFile.odl”
它在生成的文件(“MyIDLFile.h”)中变成
包含“MyODLFile.h”
的语句,当我需要它时, generate
include "MyODLFile_h.h"
如何指定 IDL 在导入语句中生成的文件名?
I'm working on a legacy c++ COM project that I'm moving over to Visual Studio 2010. In the IDL file for this project, I have to reference an ODL file from another c++ project. My problem is that the other project generates its header file as $(filename)_h.h. When my IDL file generates its header file, it generates the ODL filename as $filename.h, and it can't reference the correct file.
In other words, in my IDL file ("MyIDLFile.idl") I have a statement like
import "MyODLFile.odl"
which in the generated file ("MyIDLFile.h") becomes
include "MyODLFile.h"
when I need it to generate
include "MyODLFile_h.h"
How do I specify the file name I want the IDL to generate in an import statement?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不确定您对导入语句的含义,但您要查找的内容可能可以在项目的属性下找到。转到属性窗口 (Alt-F7),在“配置属性/MIDL/输出”下,您将有机会声明您希望创建的头文件。由于您的项目是旧项目,因此从头文件名中删除“_h”可能会更容易(例如 $(ProjectName).h 而不是 $(ProjectName)_h.h)。请参阅 http://support.microsoft.com/kb/321274 了解更多信息。
I'm not sure what you mean about the import statement, but what you're looking for might be found under the project's Properties. Goto the properties window (Alt-F7) and under "Configuration Properties/MIDL/Output", you'll have the opportunity to declare the Header File which you want it to create. Since your project is legacy, it may be easier to just remove the "_h" from the header file name (e.g. $(ProjectName).h instead of $(ProjectName)_h.h). See http://support.microsoft.com/kb/321274 for a lil more info.
这是处理 IDL 文件时需要解决的常见问题。好处是有几种方法可以解决这个问题:
您的最终解决方案可能会使用#1 和#2 中的一些内容。
MIDL 编译器有几个选项< /a> 修改输出文件的名称,或排除输出文件。
直接指定名称:
跳过输出文件:
我个人过去曾使用 /prefix 选项来避免标头的名称冲突。
这是一个例子:
带有方法 foo 的接口将在标头中重命名为 HIDE_foo 。
另一种有效的策略与如何分层目录、构建顺序和发布文件、使用包含路径以及对实际包含进行排序有关。我只习惯使用 dir 文件和 build.exe 的源代码,所以我无法给出任何关于 VS 的工作方式的建议。
This is a common problem to solve when dealing with IDL files. The good thing is that there are a few ways to solve this problem:
Your ultimate solution may use a little of #1 and #2.
The MIDL compiler has several options to modify the names of output files, or excluding output files.
Directly specifying names:
Skipping output files:
I personally have used the /prefix option to avoid name collisions of headers in the past.
This is an example of that:
The interface with method foo would be renamed to HIDE_foo in the header.
The other strategy that works is related to how you layer your directories, build order, and publish files, and use include paths, and order the actual includes. I am only used to using sources with dir files, and build.exe, so I can't give any advice how that works with VS.
这似乎是一个常见问题,我一直无法找到任何好的解决方案,但一种解决方法是在 idl 文件中附加“_i”,例如 EquipmentConstants_i.idl
Microsoft 确实引用了 /header 编译开关,但我没有引用无法让它工作(midl / header 开关)。
This seems to be a common problem, I haven't been able to find any good solution but one workaround is to append a '_i" to your idl files, e.g. EquipmentConstants_i.idl
Microsoft does reference a /header compile switch but I haven't been able to get that to work (midl /header switch).