Directive
A #line sets the compiler setting for the current file name and line number. This affects the characters __FILE__ and __LINE__ , the output is generated by failed assert() and diagnostic messages (errors and warnings). It is usually used by the preprocessor, so error messages and warnings may refer to the source code, and not to the output of the preprocessor (which is usually discarded by the time you see any messages).
It is also used by other tools that generate C source code, such as lex / flex and yacc / bison, so error messages may refer to the input file rather than the (temporary) C code.
Definitive reference C standard (pdf), section 6.10.4.
View line
#line number
sets the current line number. View line
#line number "file-name"
sets the line number and file name. You can also generate one of these two forms by expanding macros; eg:
#define LINE 42 #define FILE "foo.c" #line LINE FILE
source share