Files
2025-10-25 03:02:53 +03:00

71 lines
2.9 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[cpp.line]
# 15 Preprocessing directives [[cpp]](./#cpp)
## 15.8 Line control [cpp.line]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/preprocessor.tex#L2066)
The [*string-literal*](lex.string#nt:string-literal "5.13.5String literals[lex.string]") of a#line directive, if present,
shall be a character string literal[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/preprocessor.tex#L2072)
The[*line number*](#def:line_number "15.8Line control[cpp.line]") of the current source line is
the line number of the current physical source line,
i.e., it is one greater than
the number of new-line characters read or introduced
in [translation phase 1](lex.phases "5.2Phases of translation[lex.phases]") while processing the source file to the current preprocessing token[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/preprocessor.tex#L2082)
A preprocessing directive of the form
# line [*digit-sequence*](lex.fcon#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]") [*new-line*](cpp.pre#nt:new-line "15.1Preamble[cpp.pre]")
causes the implementation to behave as if
the following sequence of source lines begins with a
source line that has a line number as specified
by the digit sequence (interpreted as a decimal integer)[.](#3.sentence-1)
If the digit sequence specifies zero
or a number greater than 2147483647,
the program is ill-formed[.](#3.sentence-2)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/preprocessor.tex#L2095)
A preprocessing directive of the form
# line [*digit-sequence*](lex.fcon#nt:digit-sequence "5.13.4Floating-point literals[lex.fcon]") " [*s-char-sequence*](lex.string#nt:s-char-sequence "5.13.5String literals[lex.string]")opt " [*new-line*](cpp.pre#nt:new-line "15.1Preamble[cpp.pre]")
sets the presumed line number similarly and changes the
presumed name of the source file to be the contents
of the character string literal[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/preprocessor.tex#L2104)
A preprocessing directive of the form
# line [*pp-tokens*](cpp.pre#nt:pp-tokens "15.1Preamble[cpp.pre]") [*new-line*](cpp.pre#nt:new-line "15.1Preamble[cpp.pre]")
(that does not match one of the two previous forms)
is permitted[.](#5.sentence-1)
The preprocessing tokens afterline on the directive are processed just as in normal text
(each identifier currently defined as a macro name is replaced by its
replacement list of preprocessing tokens)[.](#5.sentence-2)
If the directive resulting after all replacements does not match
one of the two previous forms, the program is ill-formed;
otherwise, the result is processed as appropriate[.](#5.sentence-3)