XL Fortran for AIX 8.1

Language Reference

#line

Purpose

The #line directive associates code that is created by cpp or any other Fortran source code generator with input code created by the programmer. Because the preprocessor may cause lines of code to be inserted or deleted, the #line directive can be useful in error reporting and debugging because it identifies which lines in the original source caused the preprocessor to generate the corresponding lines in the intermediate file.

Format



>>-#line--line_number--+----------+----------------------------><
                       '-filename-'
 
 

The #line directive is a noncomment directive and follows the syntax rules for this type of directive.

line_number
is a positive, unsigned integer literal constant without a KIND parameter. You must specify line_number.

filename
is a character literal constant, with no kind type parameter. The filename may specify a full or relative path. The filename as specified will be recorded for use later. If you specify a relative path, when you debug the program the debugger will use its directory search list to resolve the filename.

Rules

The #line directive follows the same rules as other noncomment directives, with the following exceptions:

The #line directive indicates the origin of all code following the directive in the current file. Another #line directive will override a previous one.

If you supply a filename, the subsequent code in the current file will be as if it originated from that filename. If you omit the filename, and no previous #line directive with a specified filename exists in the current file, the code in the current file is treated as if it originated from the current file at the line number specified. If a previous #line directive with a specified filename does exist in the current file, the filename from the previous directive is used.

line_number indicates the position, in the appropriate file, of the line of code following the directive. Subsequent lines in that file are assumed to have a one to one correspondence with subsequent lines in the source file until another #line directive is specified or the file ends.

When XL Fortran invokes cpp for a file, the preprocessor will emit #line directives unless you also specify the -d option.

Examples

The file test.F contains:

!  File test.F, Line 1
#include "test.h"
PRINT*, "test.F Line 3"
...
PRINT*, "test.F Line 6"
#include "test.h"
PRINT*, "test.F Line 8"
END

The file test.h contains:

!  File test.h line 1
RRINT*,1             ! Syntax Error
PRINT*,2

After the C preprocessor (/lib/cpp) processes the file test.F with the default options:

#line 1 "test.F"
! File test.F, Line 1
#line 1 "test.h"
! File test.h Line 1
RRINT*,1            ! Syntax Error
PRINT*,2
#line 3 "test.F"
PRINT*, "test.F Line 3"
...
#line 6
PRINT*, "test.F Line 6"
#line 1 "test.h"
!  File test.h Line 1
RRINT*,1            ! Syntax Error
PRINT*,2
#line 8 "test.F"
PRINT*, "test.F Line 8"
END

The compiler displays the following messages after it processes the file that is created by the C preprocessor:

2       2 |RRINT*,1
!Syntax error
            ......a................
a - "t.h", line 2.6: 1515-019 (S) Syntax is incorrect.
 
4       2 |RRINT*,1            !Syntax error
            ......a................
a - "t.h", line 2.6: 1515-019 (S) Syntax is incorrect.

Related Information


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]