在 midl 生成的头文件中定义结构体

发布于 2024-08-11 17:32:06 字数 297 浏览 3 评论 0原文

我正在自动化构建遗留产品,但遇到了困难...

我有一个 .idl 文件,它是使用 midl 在 VC++ 6.0 中编译的,以生成 .tlb、.h 和 .c 文件,该文件具有要添加的手动构建步骤:

struct StructDef;

位于生成的 .h 文件中的 MIDL_INTERFACE 之前。 .h 文件的其余部分使用该定义,在添加此定义之前我无法编译。

我正在寻找一种使用结构定义自动生成头文件的方法(首选),或者至少是一种通过自定义构建步骤自动执行此代码添加步骤的方法。

I am in the process of automating the build of a legacy product and have hit a wall...

I have a .idl file that is compiled in VC++ 6.0 using midl to generate a .tlb, .h and .c file that has a manual build step to add:

struct StructDef;

Just ahead of an MIDL_INTERFACE in the generated .h file. The rest of the .h file uses the definition, and I cannot compile until this is added.

I am looking for a way to autogenerate the header file with the struct definition (preferred), or at least a way to automate this code adding step through a custom build step.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悲凉≈ 2024-08-18 17:32:06

#pragma midl_echo 指示 MIDL 将任意文本插入生成的头文件中。您可以这样使用它:

#pragma midl_echo("struct StructDef;")

看来 < code>cpp_quote 属性提供类似的功能。

或者,如果您安装了 Cygwin,您可能会发现后处理更简单(或者更好)自定义构建步骤中使用 sed 的头文件。那也行。

#pragma midl_echo instructs MIDL to insert an arbitrary piece of text into the generated header file. You can use it like this:

#pragma midl_echo("struct StructDef;")

It appears that the cpp_quote attribute provides similar functionality.

Alternatively, if you have Cygwin installed, you may find it simpler (or just preferable) to post-process the header file with sed in a custom build step. That would work as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文