views:

197

answers:

1

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.

+2  A: 

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

Emerick Rogul
Perfect - I used the #pragma
Rob Hunter