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

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

<pre><code>#if !defined(_M_IA64) &amp;&amp; !defined(_M_AMD64)
</code></pre>

<p>For x64, the file starts with:</p>

<pre><code>#if defined(_M_AMD64)
</code></pre>

<p>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.</p>

<p>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.</p>

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

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.