We do have a project wich uses the MIDL tool to create specific header/iid and proxy files. Those files are compiled and linked with the rest of the project using a post build step that calls nmake.
Is it possible to use precompiled headers with thos IDL generated files? How can I inject #include "stdafx-h" and remove other included headers?
Use the /FI option (Force Include): “This option has the same effect as specifying the file with double quotation marks in an #include directive on the first line of every source file specified on the command line, in the CL environment variable, or in a command file.”
It won’t remove the other headers, but this is not necessary for the Precompiled Header to be used… All the headers that you want to precompile should be included by stdafx.h. Then, provided the files have inclusion guards, it won’t be a problem when they are included again in the sources.
Example
Generated
a.cppfile:Suppose you want to pre-compile
a.handb.h. Then you create the file stdafx.h:And then you use the /FI option to have this stdafx.h included as the first file into
a.cpp. If the filesa.handb.hhave include guards, leaving them ina.cppis not an issue…