From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/preprocessor%2Fline.html | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 devdocs/c/preprocessor%2Fline.html (limited to 'devdocs/c/preprocessor%2Fline.html') diff --git a/devdocs/c/preprocessor%2Fline.html b/devdocs/c/preprocessor%2Fline.html new file mode 100644 index 00000000..92993911 --- /dev/null +++ b/devdocs/c/preprocessor%2Fline.html @@ -0,0 +1,37 @@ +

Filename and line information

Changes the current line number and file name in the preprocessor.

+

Syntax

+ + +
#line lineno (1)
#line lineno "filename" (2)

Explanation

+1) Changes the current preprocessor line number to lineno. Occurrences of the macro __LINE__ beyond this point will expand to lineno plus the number of actual source code lines encountered since.
+2) Also changes the current preprocessor file name to filename. Occurrences of the macro __FILE__ beyond this point will produce filename.

Any preprocessing tokens (macro constants or expressions) are permitted as arguments to #line as long as they expand to a valid decimal integer optionally following a valid character string.

+

lineno must be a sequence of at least one decimal digit (the program is ill-formed, otherwise) and is always interpreted as decimal (even if it starts with 0).

+

If lineno is 0 or greater than 32767(until C99)2147483647(since C99), the behavior is undefined.

+

Notes

This directive is used by some automatic code generation tools which produce C source files from a file written in another language. In that case, #line directives may be inserted in the generated C file referencing line numbers and the file name of the original (human-editable) source file.

+

The line number following the directive #line __LINE__ is unspecified (there are two possible values that __LINE__ can expand to in this case: number of endlines seen so far, or number of endlines seen so far plus the endline that ends the #line directive). This is the result of DR 464, which applies retroactively.

+

Example

#include <assert.h>
+#define FNAME "test.c"
+int main(void)
+{
+#line 777 FNAME
+        assert(2+2 == 5);
+}

Possible output:

+
test: test.c:777: int main(): Assertion `2+2 == 5' failed.

References

See also

+
C++ documentation for Filename and line information
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/preprocessor/line +

+
-- cgit v1.2.3