From Jason Turner

[cpp.include]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpw1ay24up/{from.md → to.md} +52 -33
tmp/tmpw1ay24up/{from.md → to.md} RENAMED
@@ -1,58 +1,77 @@
1
  ## Source file inclusion <a id="cpp.include">[[cpp.include]]</a>
2
 
3
- A `#include` directive shall identify a header or source file that can
4
- be processed by the implementation.
 
 
5
 
6
- A preprocessing directive of the form
7
-
8
- ``` bnf
9
- '# include <' h-char-sequence '>' new-line
10
- ```
11
-
12
- searches a sequence of *implementation-defined* places for a header
13
- identified uniquely by the specified sequence between the `<` and `>`
14
- delimiters, and causes the replacement of that directive by the entire
15
- contents of the header. How the places are specified or the header
16
- identified is *implementation-defined*.
17
 
18
  A preprocessing directive of the form
19
 
20
  ``` bnf
21
- '# include "' q-char-sequence '"' new-line
22
  ```
23
 
24
  causes the replacement of that directive by the entire contents of the
25
- source file identified by the specified sequence between the `"`
26
- delimiters. The named source file is searched for in an
27
- *implementation-defined* manner. If this search is not supported, or if
28
- the search fails, the directive is reprocessed as if it read
 
 
 
 
 
 
 
 
29
 
30
  ``` bnf
31
- '# include <' h-char-sequence '>' new-line
32
  ```
33
 
34
- with the identical contained sequence (including `>` characters, if any)
35
- from the original directive.
 
 
 
 
 
 
 
 
36
 
37
  A preprocessing directive of the form
38
 
39
  ``` bnf
40
  '# include' pp-tokens new-line
41
  ```
42
 
43
- (that does not match one of the two previous forms) is permitted. The
44
- preprocessing tokens after `include` in the directive are processed just
45
- as in normal text (i.e., each identifier currently defined as a macro
46
- name is replaced by its replacement list of preprocessing tokens). If
47
- the directive resulting after all replacements does not match one of the
48
- two previous forms, the behavior is undefined.[^4]
 
 
 
 
 
49
 
50
- The method by which a sequence of preprocessing tokens between a `<` and
51
- a `>` preprocessing token pair or a pair of `"` characters is combined
52
- into a single header name preprocessing token is
53
- *implementation-defined*.
54
 
55
  The implementation shall provide unique mappings for sequences
56
  consisting of one or more *nondigit*s or *digit*s [[lex.name]] followed
57
  by a period (`.`) and a single *nondigit*. The first character shall not
58
  be a *digit*. The implementation may ignore distinctions of alphabetical
@@ -66,14 +85,14 @@ If the header identified by the *header-name* denotes an importable
66
  header [[module.import]], it is *implementation-defined* whether the
67
  `#include` preprocessing directive is instead replaced by an `import`
68
  directive [[cpp.import]] of the form
69
 
70
  ``` bnf
71
- 'import' header-name ';' new-line
72
  ```
73
 
74
- [*Note 1*:
75
 
76
  An implementation can provide a mechanism for making arbitrary source
77
  files available to the `< >` search. However, using the `< >` form for
78
  headers provided with the implementation and the `" "` form for sources
79
  outside the control of the implementation achieves wider portability.
 
1
  ## Source file inclusion <a id="cpp.include">[[cpp.include]]</a>
2
 
3
+ A *header search* for a sequence of characters searches a sequence of
4
+ places for a header identified uniquely by that sequence of characters.
5
+ How the places are determined or the header identified is
6
+ *implementation-defined*.
7
 
8
+ A *source file search* for a sequence of characters attempts to identify
9
+ a source file that is named by the sequence of characters. The named
10
+ source file is searched for in an *implementation-defined* manner. If
11
+ the implementation does not support a source file search for that
12
+ sequence of characters, or if the search fails, the result of the source
13
+ file search is the result of a header search for the same sequence of
14
+ characters.
 
 
 
 
15
 
16
  A preprocessing directive of the form
17
 
18
  ``` bnf
19
+ '# include' header-name new-line
20
  ```
21
 
22
  causes the replacement of that directive by the entire contents of the
23
+ header or source file identified by *header-name*.
24
+
25
+ If the *header-name* is of the form
26
+
27
+ ``` bnf
28
+ '<' h-char-sequence '>'
29
+ ```
30
+
31
+ a header is identified by a header search for the sequence of characters
32
+ of the *h-char-sequence*.
33
+
34
+ If the *header-name* is of the form
35
 
36
  ``` bnf
37
+ '"' q-char-sequence '"'
38
  ```
39
 
40
+ the source file or header is identified by a source file search for the
41
+ sequence of characters of the *q-char-sequence*.
42
+
43
+ If a header search fails, or if a source file search or header search
44
+ identifies a header or source file that cannot be processed by the
45
+ implementation, the program is ill-formed.
46
+
47
+ [*Note 1*: If the header or source file cannot be processed, the
48
+ program is ill-formed even when evaluating
49
+ `__has_include`. — *end note*]
50
 
51
  A preprocessing directive of the form
52
 
53
  ``` bnf
54
  '# include' pp-tokens new-line
55
  ```
56
 
57
+ (that does not match the previous form) is permitted. The preprocessing
58
+ tokens after `include` in the directive are processed just as in normal
59
+ text (i.e., each identifier currently defined as a macro name is
60
+ replaced by its replacement list of preprocessing tokens). Then, an
61
+ attempt is made to form a *header-name* preprocessing token
62
+ [[lex.header]] from the whitespace and the characters of the spellings
63
+ of the resulting sequence of preprocessing tokens; the treatment of
64
+ whitespace is *implementation-defined*. If the attempt succeeds, the
65
+ directive with the so-formed *header-name* is processed as specified for
66
+ the previous form. Otherwise, the program is ill-formed, no diagnostic
67
+ required.
68
 
69
+ [*Note 2*: Adjacent *string-literal*s are not concatenated into a
70
+ single *string-literal* (see the translation phases in  [[lex.phases]]);
71
+ thus, an expansion that results in two *string-literal*s is an invalid
72
+ directive. — *end note*]
73
 
74
  The implementation shall provide unique mappings for sequences
75
  consisting of one or more *nondigit*s or *digit*s [[lex.name]] followed
76
  by a period (`.`) and a single *nondigit*. The first character shall not
77
  be a *digit*. The implementation may ignore distinctions of alphabetical
 
85
  header [[module.import]], it is *implementation-defined* whether the
86
  `#include` preprocessing directive is instead replaced by an `import`
87
  directive [[cpp.import]] of the form
88
 
89
  ``` bnf
90
+ import header-name ';' new-line
91
  ```
92
 
93
+ [*Note 3*:
94
 
95
  An implementation can provide a mechanism for making arbitrary source
96
  files available to the `< >` search. However, using the `< >` form for
97
  headers provided with the implementation and the `" "` form for sources
98
  outside the control of the implementation achieves wider portability.