The canonical solution is easy: do not include the precompiled header file (default is stdafx.h). If your code needs to be compiled with precompiled headers, use the / FI (Name Forced Include File) compiler:
This option has the same effect as specifying a double-quoted file in the #include directive on the first line of each source file specified on the command line, in a CL environment variable, or in a command file.
This allows you to use precompiled header files without changing the source code.
Rules for using the #include directive with double quotes are described in # include Directive (C / C ++) :
Quote form:
The preprocessor searches for included files in the following order:
- In the same directory as the file containing the #include statement.
- In directories of open include files, in the reverse order in which they were opened. The search begins in the directory of the parent include file and continues up through the directories of any files with grandparents.
- The path specified by each / I compiler option.
- Along the way, set by the INCLUDE environment variable.
Using / I (optional Include directories) , the compiler will include the directory of the header file used to generate the precompiled header, then itβs just possible to write
/FIstdafx.hpp
There is no combination of project settings / topology that allows you to enable or disable precompiled headers. The compiler switches / Y , / FI and / I must be used together or completely removed. To change a set of configurations as a unit, you can use property pages (for more details see Working with Project Properties ).
source share