Can precompiled headers be used with generated MIDL files?
We have a project that uses the MIDL tool to generate specific header / iid and proxy files. These files are compiled and linked to the rest of the project using a post build step that calls nmake.
Can precompiled headers be used with generated IDL files? How can I insert #include "stdafx-h"
and remove other included headers?
source to share
Use the / FI (Force Include) option: "This option has the same effect as specifying a double-quoted file in the #include directive on the first line of every source file specified on the command line, in a CL environment variable, or in a command file."
It will not remove other headers, but it is not necessary to use Precompiled Header ... All headers you want to precompile must be included in stdafx.h. Then, if the files have include defenders, it won't be a problem if they are included in sources again.
Example
Generated file a.cpp
:
#include <a.h>
#include <b.h>
//rest of the code
Let's say you want to precompile a.h
and b.h
. Then you create the stdafx.h file:
#include <a.h>
#include <b.h>
And then you use the / FI option to have this stdafx.h included as the first file in the a.cpp
. If the files a.h
and b.h
have included guards , leaving them a.cpp
is not a problem ...
source to share