16.7.1 ‘#line’ Directive

An input line such as this:

#line 100 "foo.ptexi"

indicates that the next line was line 100 of the file foo.ptexi, and so that’s what an error message should refer to. Both M4 (see Preprocessor features in GNU M4) and CPP (see Line Control in The C Preprocessor, and Preprocessor Output in The C Preprocessor) can generate such lines.

The texi2any program recognizes these lines by default, except within @verbatim blocks (see @verbatim: Literal Text). Their recognition can be turned off completely with CPP_LINE_DIRECTIVES (see Other Customization Variables), though there is normally no reason to do so.

For those few programs (M4, CPP, Texinfo) which need to document ‘#line’ directives and therefore have examples which would otherwise match the pattern, the command @hashchar{} can be used (see Inserting ‘#’ with @hashchar{}). The example line above looks like this in the source for this manual:

@hashchar{}line 100 "foo.ptexi"

The @hashchar command was added to Texinfo in 2013. If you don’t want to rely on it, you can also use @set and @value to insert the literal ‘#’:

@set hash #
@value{hash}line 1 "example.c"

Or, if suitable, a @verbatim environment can be used instead of @example. As mentioned above, #line-recognition is disabled inside verbatim blocks.