File inclusion
The &include directive instructs the preprocessor to include a
file.
Syntax
&include "filename"
- filename is the file to be included during preprocessing.
Usage
The file to be included is searched first in the directory containing the current file, then in
the directorie(s) provided with -I
option.
filename can be followed by spaces and comments.
The included file will be scanned and processed before continuing with the rest of the current file.
Source: File A
First line
&include "B"
Third lineSource: File B
Second lineResult:
& 1 "A"
First line
& 1 "B"
Second line
& 3 "A"
Third lineThese preprocessor directives inform the compiler of its current location with special preprocessor comments, so the compiler can provide the right error message when a syntax error occurs.
The preprocessor-generated comments use the following
format:
& number "filename"where:
- number is the current line in the preprocessed file
- filename is the current file name
Recursive inclusions
Recursive inclusions are not allowed. Doing so will fail and output an error message.
The following example is incorrect:
Source: File A
&include "B"Source: File B
HELLO
&include "A"fglcomp -M A.4gl
outputB.4gl:2:1:2:1:error:(-8029) Multiple inclusion of the source file 'A'.Including the same file several times is allowed:
Source: File A
&include "B"
&include "B" -- correctSource: File B
HELLOResult:
& 1 "A"
& 1 "B"
HELLO
& 2 "A"
& 1 "B"
HELLO