MIDL为/env win32和/env win64生成相同的文件 [英] MIDL generates the same file for /env win32 and /env win64

查看:138
本文介绍了MIDL为/env win32和/env win64生成相同的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio中,编译foo.idl时,MIDL在foo_p.c中生成代理信息.

In Visual Studio, when you compile foo.idl, MIDL generates the proxy information in foo_p.c.

不幸的是,对于Win32和x64文件,它使用相同的文件名.对于Win32,文件开头为:

Unfortunately, for Win32 and x64 files, it uses the same filename. For Win32, the file starts with:

#if !defined(_M_IA64) && !defined(_M_AMD64)

对于x64,文件开头为:

For x64, the file starts with:

#if defined(_M_AMD64)

当您为Win32进行构建,然后立即为x64进行构建时,它不会替换foo_p.c文件,这意味着该项目无法链接.

When you build for Win32 and then immediately build for x64, it doesn't replace the foo_p.c file, meaning that the project fails to link.

我尝试过一个预构建事件,如果它用于错误的体系结构,则会删除foo_p.c文件,但是VS甚至不费心去执行该步骤.

I tried having a pre-build event that deletes the foo_p.c file if it's for the wrong architecture, but VS doesn't even bother to run that step.

我应该如何获得它,以便可以先构建一个配置,然后再构建另一个配置?

How should I get it so that I can build one configuration and then the other?

推荐答案

您可以修改IDL文件的编译器设置,以根据目标平台为输出代理文件指定其他文件名. (选择IDL文件上的属性",然后选择配置属性"/"MIDL"/输出").

You could modify the compiler settings for your IDL file to specify a different file name for the output proxy file according to the target platform. (Select Properties on the IDL file, then Configuration Properties / MIDL / Output).

  • 对于Win32版本,请使用foo_p_w32.c
  • 对于x64构建,请使用foo_p_x64.c
  • For Win32 builds, use foo_p_w32.c
  • For x64 builds, use foo_p_x64.c

然后,在Win32项目设置中,排除x64项目的文件foo_p_x64.c,反之亦然.

Then, in your Win32 project settings, exclude the file foo_p_x64.c and vice versa for the x64 project.

您需要对_i.c文件执行相同的操作,否则Visual Studio似乎根本不会重建IDL.

You need to do the same for the _i.c file, otherwise Visual Studio doesn't seem to rebuild the IDL at all.

这篇关于MIDL为/env win32和/env win64生成相同的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆