Next: Idiomatic C Up: The C Preprocessor Previous: if ifdef ifndef

line

You will not normally need this, but it is the only preprocessor operation we have not covered.

It has the syntax:

#line constant identifier

and causes the compiler to believe, for diagnostic purposes, that the line number of the next source line is given by the constant and that the current source file is called identifier (the latter is optional).

In fact the commonest use of this is by the pre-processor itself! When you use #include, the effect is as if the one file were physically included in another. The result is that any errors would be reported as at the appropriate line in the composite file, which is not helpful when you want to know which line in which (separate) file. Hence the pre-processor itself inserts #line directives at the start of each #include etc, to make the line numbers and filenames come out the way you would expect.

You can see this with cc -E, if you are interested.



Next: Idiomatic C Up: The C Preprocessor Previous: if ifdef ifndef


maspjw@
Tue Sep 27 15:29:34 BST 1994