How to create x86 and x64 code using MIDL?

How can I generate code for x86 and x64 using MIDL?

I created an IDL file in Visual Studio 2010, and when I compile the product both in x86 mode and then in x64, I need to “touch” the IDL file so that it updates the code for x64. Can I somehow tell MIDL to generate both codes in the same file?

+4
source share
3 answers

An IDL file defines an interface; this interface can use 64-bit platform functions or 32-bit platform functions. IDL can be used to create stubs; if the interface does not have definitions based on a 32-bit platform or definitions defined on a 64-bit platform, it is possible that a stub can be generated (that is, one IDL file). But it depends on the interfaces you are viewing. Short answer: if you determine that the interfaces are compatible with 32-bit and 64-bit, you do not need two different IDL files - otherwise you need two different IDL files.

Not knowing what “touch” means (which usually means updating the file’s date / time, wrt software engineering), it’s hard to say exactly what you need to do.

0
source

If you link to files in the Generated Files folder, you won’t see their changes if everything you change is the target platform (well, if you do not place the #ifdef blocks in the IDL, it defines the specific ones). Remember that MIDL output is source code, not binary files. The data type names used in the generated code will not change, so the output from the MIDL will be the same even if the architecture of the machine the compiler is targeting is different.

You can verify this by making copies of the files XXX_i.h and XXX_i.c and comparing them between platforms. To do this, create, create copies, rebuild, then compare the files; the only thing that should be different is the timestamp.

So, to return to the original question: you are already doing this!

0
source

I know this is an old question, but if someone else hit it, that’s how I solved it.

In the project containing the IDL file, I added a pre-build event for all platforms and configurations that deleted MIDL output files, such as ...

if exist $(ProjectName).h del $(ProjectName).h if exist $(ProjectName)_i.c del $(ProjectName)_i.c if exist $(ProjectName)_p.c del $(ProjectName)_p.c 

I could get rid of just deleting the proxy (_p) file as the only MIDL file created with a specific platform.

If your source proxy stub files have different names or extensions, use them.

0
source

All Articles