Skip to content

Commit 0fa9356

Browse files
authored
Merge pull request #276 from Microsoft/cr_pch
Merge PCH docs
2 parents d6eb43b + 96b446e commit 0fa9356

15 files changed

+372
-702
lines changed

docs/build/reference/TOC.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,6 @@
145145
#### [-Zs (Syntax Check Only)](zs-syntax-check-only.md)
146146
#### [-ZW (Windows Runtime Compilation)](zw-windows-runtime-compilation.md)
147147
## [Creating Precompiled Header Files](creating-precompiled-header-files.md)
148-
### [When to Precompile Source Code](when-to-precompile-source-code.md)
149-
### [Two Choices for Precompiling Code](two-choices-for-precompiling-code.md)
150-
### [Precompiled Header Consistency Rules](precompiled-header-consistency-rules.md)
151-
#### [Consistency Rules for Per-File Use of Precompiled Headers](consistency-rules-for-per-file-use-of-precompiled-headers.md)
152-
#### [Consistency Rules for -Yc and -Yu](consistency-rules-for-yc-and-yu.md)
153-
### [Using Precompiled Headers in a Project](using-precompiled-headers-in-a-project.md)
154-
#### [PCH Files in the Build Process](pch-files-in-the-build-process.md)
155-
#### [Sample Makefile for PCH](sample-makefile-for-pch.md)
156-
#### [Example Code for PCH](example-code-for-pch.md)
157148
## [Unicode Support in the Compiler and Linker](unicode-support-in-the-compiler-and-linker.md)
158149
# [Linking](linking.md)
159150
## [Setting Linker Options](setting-linker-options.md)
Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,3 @@
11
---
2-
title: "Consistency Rules for Per-File Use of Precompiled Headers | Microsoft Docs"
3-
ms.custom: ""
4-
ms.date: "11/04/2016"
5-
ms.reviewer: ""
6-
ms.suite: ""
7-
ms.technology:
8-
- "cpp-tools"
9-
ms.tgt_pltfrm: ""
10-
ms.topic: "article"
11-
dev_langs:
12-
- "C++"
13-
helpviewer_keywords:
14-
- "precompiled header files, consistency rules"
15-
- "PCH files, consistency rules"
16-
- ".pch files, consistency rules"
17-
ms.assetid: afd49365-48bc-41f4-b700-fe8297b944a1
18-
caps.latest.revision: 6
19-
author: "corob-msft"
20-
ms.author: "corob"
21-
manager: "ghogen"
22-
translation.priority.ht:
23-
- "cs-cz"
24-
- "de-de"
25-
- "es-es"
26-
- "fr-fr"
27-
- "it-it"
28-
- "ja-jp"
29-
- "ko-kr"
30-
- "pl-pl"
31-
- "pt-br"
32-
- "ru-ru"
33-
- "tr-tr"
34-
- "zh-cn"
35-
- "zh-tw"
36-
---
37-
# Consistency Rules for Per-File Use of Precompiled Headers
38-
The [/Yu](../../build/reference/yu-use-precompiled-header-file.md) compiler option lets you specify which precompiled header (PCH) file to use.
39-
40-
When you use a PCH, the compiler assumes the same compilation environment — using consistent compiler options, pragmas, and so on — that was in effect when you created the PCH, unless you specify otherwise. If the compiler detects an inconsistency, it issues a warning and identifies the inconsistency where possible. Such warnings do not necessarily indicate a problem with the PCH; they simply warn you of possible conflicts. Consistency requirements for PCHs are described in the following sections.
41-
42-
## Compiler Option Consistency
43-
The following compiler options can trigger an inconsistency warning when using a PCH:
44-
45-
- Macros created using the Preprocessor (/D) option must be the same between the compilation that created the PCH and the current compilation. The state of defined constants is not checked, but unpredictable results can occur if these change.
46-
47-
- PCHs do not work with the /E and /EP options.
48-
49-
- PCHs must be created using either the Generate Browse Info (/FR) option or the Exclude Local Variables (/Fr) option before subsequent compilations that use the PCH can use these options.
50-
51-
## C 7.0-Compatible (/Z7)
52-
If this option is in effect when the PCH is created, subsequent compilations that use the PCH can use the debugging information.
53-
54-
If the C 7.0-Compatible (/Z7) option is not in effect when the PCH is created, subsequent compilations that use the PCH and /Z7 trigger a warning. The debugging information is placed in the current .obj file, and local symbols defined in the PCH are not available to the debugger.
55-
56-
## Include Path Consistency
57-
A PCH does not contain information about the include path that was in effect when it was created. When you use a .pch file, the compiler always uses the include path specified in the current compilation.
58-
59-
## Source File Consistency
60-
When you specify the Use Precompiled Header File (/Yu) option, the compiler ignores all preprocessor directives (including pragmas) that appear in the source code that will be precompiled. The compilation specified by such preprocessor directives must be the same as the compilation used for the Create Precompiled Header File (/Yc) option.
61-
62-
## Pragma Consistency
63-
Pragmas processed during the creation of a PCH usually affect the file with which the PCH is subsequently used. The comment and message pragmas do not affect the remainder of the compilation.
64-
65-
The following pragmas are retained as part of a PCH, and affect the remainder of a compilation that uses the PCH.
66-
67-
||||
68-
|-|-|-|
69-
|alloc_text|include_alias|pack|
70-
|auto_inline|init_seg|pointers_to_members|
71-
|check_stack|inline_depth|setlocale|
72-
|code_seg|inline_recursion|vtordisp|
73-
|data_seg|intrinsic|warning|
74-
|function|optimize||
75-
76-
## See Also
77-
[Precompiled Header Consistency Rules](../../build/reference/precompiled-header-consistency-rules.md)
78-
[/Yu (Use Precompiled Header File)](../../build/reference/yu-use-precompiled-header-file.md)
79-
[Compiler Options](../../build/reference/compiler-options.md)
2+
redirect_url: /cpp/build/reference/creating-precompiled-header-files#consistency-rules-for-per-file-use-of-precompiled-headers
3+
---
Lines changed: 2 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,3 @@
11
---
2-
title: "Consistency Rules for -Yc and -Yu | Microsoft Docs"
3-
ms.custom: ""
4-
ms.date: "11/04/2016"
5-
ms.reviewer: ""
6-
ms.suite: ""
7-
ms.technology:
8-
- "cpp-tools"
9-
ms.tgt_pltfrm: ""
10-
ms.topic: "article"
11-
f1_keywords:
12-
- "/yc"
13-
- "/yu"
14-
dev_langs:
15-
- "C++"
16-
helpviewer_keywords:
17-
- "Yu compiler option [C++]"
18-
- "/Yu compiler option [C++]"
19-
- "-Yu compiler option [C++]"
20-
- "-Yc compiler option [C++]"
21-
- "/Yc compiler option [C++]"
22-
- "Yc compiler option [C++]"
23-
ms.assetid: 9dfb0e32-ec9b-4a36-9355-27a0e5fba512
24-
caps.latest.revision: 6
25-
author: "corob-msft"
26-
ms.author: "corob"
27-
manager: "ghogen"
28-
translation.priority.ht:
29-
- "cs-cz"
30-
- "de-de"
31-
- "es-es"
32-
- "fr-fr"
33-
- "it-it"
34-
- "ja-jp"
35-
- "ko-kr"
36-
- "pl-pl"
37-
- "pt-br"
38-
- "ru-ru"
39-
- "tr-tr"
40-
- "zh-cn"
41-
- "zh-tw"
42-
---
43-
# Consistency Rules for /Yc and /Yu
44-
When you use a precompiled header created using /Yc or /Yu, the compiler compares the current compilation environment to the one that existed when you created the .pch file. Be sure to specify an environment consistent with the previous one (using consistent compiler options, pragmas, and so on) for the current compilation. If the compiler detects an inconsistency, it issues a warning and identifies the inconsistency where possible. Such warnings don't necessarily indicate a problem with the .pch file; they simply warn you of possible conflicts. The following sections explain the consistency requirements for precompiled headers.
45-
46-
## Compiler Option Consistency
47-
The following table lists compiler options that might trigger an inconsistency warning when using a precompiled header.
48-
49-
|Option|Name|Rule|
50-
|------------|----------|----------|
51-
|/D|Define constants and macros|Must be the same between the compilation that created the precompiled header and the current compilation. The state of defined constants is not checked, but unpredictable results can occur if your files depend on the values of the changed constants.|
52-
|/E or /EP|Copy preprocessor output to standard output|Precompiled headers do not work with the /E or /EP option.|
53-
|/Fr or /FR|Generate Microsoft Source Browser information|For the /Fr and /FR options to be valid with the /Yu option, they must also have been in effect when the precompiled header was created. Subsequent compilations that use the precompiled header also generate Source Browser information. Browser information is placed in a single .sbr file and is referenced by other files in the same manner as CodeView information. You cannot override the placement of Source Browser information.|
54-
|/GA, /GD, /GE, /Gw, or /GW|Windows protocol options|Must be the same between the compilation that created the precompiled header and the current compilation. If these options differ, a warning message results.|
55-
|/Zi|Generate complete debugging information|If this option is in effect when the precompiled header is created, subsequent compilations that use the precompilation can use that debugging information. If /Zi is not in effect when the precompiled header is created, subsequent compilations that use the precompilation and the /Zi option trigger a warning. The debugging information is placed in the current object file, and local symbols defined in the precompiled header are not available to the debugger.|
56-
57-
> [!NOTE]
58-
> The precompiled header facility is intended for use only with a file with C and C++ source files.
59-
60-
## Include Path Consistency
61-
A precompiled header created with /Yc does not contain information about the include path that was in effect when you created the .pch file. When you use a .pch file, the compiler always uses the include path specified in the current compilation.
62-
63-
## Source File Consistency
64-
When you use a precompiled header, the compiler ignores all preprocessor directives (including pragmas) that appear before the hdrstop pragma. The compilation specified by such preprocessor directives must be the same as the compilation used to create the precompiled header file.
65-
66-
## Pragma Consistency
67-
Pragmas processed during the compilation of a precompiled header usually affect the file in which the precompiled header is subsequently used. The following pragmas affect only the code within the .pch file; they do not affect code that subsequently uses the .pch file:
68-
69-
||||
70-
|-|-|-|
71-
|Comment|page|subtitle|
72-
|Linesize|pagesize|Title|
73-
|Message|skip||
74-
75-
The following pragmas are retained as part of a precompiled header, and affect the remainder of a compilation that uses the precompiled header:
76-
77-
||||
78-
|-|-|-|
79-
|alloc_text|function|optimize|
80-
|auto_inline|inline_depth|Pack|
81-
|check_pointer|inline_recursion|same_seg|
82-
|check_stack|intrinsic|warning|
83-
|code_seg|loop_opt||
84-
|data_seg|native_caller||
85-
86-
## See Also
87-
[Precompiled Header Consistency Rules](../../build/reference/precompiled-header-consistency-rules.md)
88-
[/Yc (Create Precompiled Header File)](../../build/reference/yc-create-precompiled-header-file.md)
89-
[/Yu (Use Precompiled Header File)](../../build/reference/yu-use-precompiled-header-file.md)
2+
redirect_url: /cpp/build/reference/creating-precompiled-header-files#consistency-rules-for-yc-and-yu
3+
---

0 commit comments

Comments
 (0)