views:

383

answers:

1

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

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

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

For x64, the file starts with:

#if defined(_M_AMD64)

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.

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?

+1  A: 

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).

  • For Win32 builds, use foo_p_w32.c
  • For x64 builds, use foo_p_x64.c

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

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

ChrisN