File inclusion
The &include directive instructs the preprocessor to include a
file.
Syntax
&include "filename"
- filename is the file to be included during preprocessing.
filename can be a relative or an absolute path. To specify a path, the slash
(
/) directory separator can be used for UNIX™ and Windows® platforms.
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.
The filename argument can be followed by spaces and comments.
The included file will be scanned and processed before continuing with the rest of the current file.
First line
&include "B"
Third lineSecond line& 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.
& 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:
&include "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:
&include "B"
&include "B" -- correctHELLO& 1 "A"
& 1 "B"
HELLO
& 2 "A"
& 1 "B"
HELLOFile path
In the &include "filename" macro,
filename can be a relative or an absolute path.
/) directory separator can be used for UNIX and Windows
platforms:&include "../include/common.inc"