Share via


Consistency Rules for /YX

If a precompiled header file exists (either MSVC.PCH or one specified by /Fpfilename), it is compared to the current compilation for consistency. Unless the following requirements are met, a new precompiled header file is created and the new file overwrites the old:

  • The current compiler options must match those specified when the precompiled header was created.

  • The current working directory must match that specified when the precompiled header was created.

  • The order and values of all #include and #pragma directives must match those specified when the precompiled header was created. These, along with #define directives, are checked one by one as they appear during subsequent compilations that use the precompiled header. The values of #define directives must match. However, a sequence of #define directives need not occur in exactly the same order because there are no semantic order dependencies for #define directives. The #pragma directives must be nearly identical, with a few exceptions; for example, multiple spaces outside of strings are treated as a single space to allow for different programming styles.

  • The value and order of include paths specified on the command line with /I options must match those specified when the precompiled header was created.

  • The time stamps of all the header files (all files specified with #include directives) used to build the precompiled header must match those that existed when the precompiled header was created.