Next: Pragmas, Previous: Diagnostics, Up: Top
The C preprocessor informs the C compiler of the location in your source code where each token came from. Presently, this is just the file name and line number. All the tokens resulting from macro expansion are reported as having appeared on the line of the source file where the outermost macro was used. We intend to be more accurate in the future.
If you write a program which generates source code, such as the
bison parser generator, you may want to adjust the preprocessor's
notion of the current file name and line number by hand. Parts of the
output from bison are generated from scratch, other parts come
from a standard parser file. The rest are copied verbatim from
bison's input. You would like compiler error messages and
symbolic debuggers to be able to refer to bison
's input file.
bison or any such program can arrange this by writing `#line' directives into the output file. `#line' is a directive that specifies the original line number and source file name for subsequent input in the current preprocessor input file. `#line' has three variants:
#line
linenum#line
linenum filename#line
anything else`#line' directives alter the results of the __FILE__
and
__LINE__
predefined macros from that point on. See Standard Predefined Macros. They do not have any effect on `#include''s
idea of the directory containing the current file.