]>
Commit | Line | Data |
---|---|---|
c63539ff ML |
1 | .. |
2 | Copyright 1988-2022 Free Software Foundation, Inc. | |
3 | This is part of the GCC manual. | |
4 | For copying conditions, see the copyright.rst file. | |
5 | ||
6 | .. _implementation-defined-behavior: | |
7 | ||
8 | .. _identifier-characters: | |
9 | ||
10 | Implementation-defined behavior | |
11 | ******************************* | |
12 | ||
13 | This is how CPP behaves in all the cases which the C standard | |
14 | describes as :dfn:`implementation-defined`. This term means that the | |
15 | implementation is free to do what it likes, but must document its choice | |
16 | and stick to it. | |
17 | ||
18 | .. todo:: Check the C++ standard for more implementation-defined stuff. | |
19 | ||
20 | * The mapping of physical source file multi-byte characters to the | |
21 | execution character set. | |
22 | ||
23 | The input character set can be specified using the | |
24 | :option:`-finput-charset` option, while the execution character set may | |
25 | be controlled using the :option:`-fexec-charset` and | |
26 | :option:`-fwide-exec-charset` options. | |
27 | ||
28 | * Identifier characters. | |
29 | ||
30 | The C and C++ standards allow identifiers to be composed of :samp:`_` | |
31 | and the alphanumeric characters. C++ also allows universal character | |
32 | names. C99 and later C standards permit both universal character | |
33 | names and implementation-defined characters. In both C and C++ modes, | |
34 | GCC accepts in identifiers exactly those extended characters that | |
35 | correspond to universal character names permitted by the chosen | |
36 | standard. | |
37 | ||
38 | GCC allows the :samp:`$` character in identifiers as an extension for | |
39 | most targets. This is true regardless of the std= switch, | |
40 | since this extension cannot conflict with standards-conforming | |
41 | programs. When preprocessing assembler, however, dollars are not | |
42 | identifier characters by default. | |
43 | ||
44 | Currently the targets that by default do not permit :samp:`$` are AVR, | |
45 | IP2K, MMIX, MIPS Irix 3, ARM aout, and PowerPC targets for the AIX | |
46 | operating system. | |
47 | ||
48 | You can override the default with :option:`-fdollars-in-identifiers` or | |
49 | :option:`-fno-dollars-in-identifiers`. See :option:`-fdollars-in-identifiers`. | |
50 | ||
51 | * Non-empty sequences of whitespace characters. | |
52 | ||
53 | In textual output, each whitespace sequence is collapsed to a single | |
54 | space. For aesthetic reasons, the first token on each non-directive | |
55 | line of output is preceded with sufficient spaces that it appears in the | |
56 | same column as it did in the original source file. | |
57 | ||
58 | * The numeric value of character constants in preprocessor expressions. | |
59 | ||
60 | The preprocessor and compiler interpret character constants in the | |
61 | same way; i.e. escape sequences such as :samp:`\\a` are given the | |
62 | values they would have on the target machine. | |
63 | ||
64 | The compiler evaluates a multi-character character constant a character | |
65 | at a time, shifting the previous value left by the number of bits per | |
66 | target character, and then or-ing in the bit-pattern of the new | |
67 | character truncated to the width of a target character. The final | |
68 | bit-pattern is given type ``int``, and is therefore signed, | |
69 | regardless of whether single characters are signed or not. | |
70 | If there are more | |
71 | characters in the constant than would fit in the target ``int`` the | |
72 | compiler issues a warning, and the excess leading characters are | |
73 | ignored. | |
74 | ||
75 | For example, ``'ab'`` for a target with an 8-bit ``char`` would be | |
76 | interpreted as :samp:`(int) ((unsigned char) 'a' * 256 + (unsigned char) | |
77 | 'b')`, and ``'\234a'`` as :samp:`(int) ((unsigned char) '\\234' * | |
78 | 256 + (unsigned char) 'a')`. | |
79 | ||
80 | * Source file inclusion. | |
81 | ||
82 | For a discussion on how the preprocessor locates header files, | |
83 | :ref:`include-operation`. | |
84 | ||
85 | * Interpretation of the filename resulting from a macro-expanded | |
86 | :samp:`#include` directive. | |
87 | ||
88 | See :ref:`computed-includes`. | |
89 | ||
90 | * Treatment of a :samp:`#pragma` directive that after macro-expansion | |
91 | results in a standard pragma. | |
92 | ||
93 | No macro expansion occurs on any :samp:`#pragma` directive line, so the | |
94 | question does not arise. | |
95 | ||
96 | Note that GCC does not yet implement any of the standard | |
3ed1b4ce | 97 | pragmas. |