Keil Logo


The #line directive specifies a line-number and optional filename for the next line in the source file.

#line line-number <[>filename<]>

C source code may come from more than one source file if the #include directive is used. The proprocessor tracks the line number and file name so that the C compiler can accurately reference lines causing errors or warnings. Additionally, accurate file name and line number details are necessary to support source-level debugging.

Third-party tools exist that may be used to generate C source code from a high-level specification language. A common use for the #line directive is to sets the source line-number and filename, in the generated source, to the actual line number and file name of the specification language file. When errors are output, the line number and file referenced will be the original specification rather than the actual C source file.

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.