Include File Processing
The EQUEL include statement provides a means to include external files in your program's source code. Its syntax is:
## include filename
Filename is a quoted string constant specifying a file name, a system environment variable that points to the file name.
You must use the default extension ".qc" in names of include files unless you override this requirement by specifying a different extension with the -n flag of the eqc command.
This statement is normally used to include variable declarations, although it is not restricted to such use. For more details on the include statement, see the QUEL Reference Guide.
The included file is preprocessed and an output file with the same name but with the default output extension ".c" is generated. You can override this default output extension with the -o.ext flag on the command line. The reference in the original source file to the included file is translated in the output file to the specified include output file. If you use the -o flag with no extension, no output file is generated for the include file. This is useful for program libraries that are using make dependencies for Linux.
If you use both the -o.ext and the -o flags, then the preprocessor generates the specified extension for the translated include statements in the programs. However, it does not generate new output files for the statements.
For example, assume that no overriding output extension is explicitly given on the command line. The EQUEL statement:
## include "employee.qc"
is preprocessed to the C statement:
# include "employee.c"
and the file "employee.qc" is translated into the C file "employee.c."
As another example, assume that a source file called "inputfile" contains the following include statement:
## include "MYDECLS";
Linux: The name "MYDECLS" can be defined as a system environment variable pointing to the file "/dev/headers/myvars.qc" by means of the following command at the system level:
setenv MYDECLS "/dev/headers/myvars.qc"
Assume now that "inputfile" is preprocessed with the command:
eqc -o.h inputfile
The command line specifies ".h" as the output file extension for include files. As the file is preprocessed, the include statement shown earlier is translated into the C statement:
# include "/dev/headers/myvars.h"
and the C file "/dev/headers/myvars.h" is generated as output for the original include file, "/dev/headers/myvars.qc."
You can also specify include files with a relative path. For example, if you preprocess the file "/dev/mysource/myfile.qc," the EQUEL statement:
## include "../headers/myvars.qc"
is preprocessed to the C statement:
# include "../headers/myvars.c"
and the C file "/dev/headers/myvars.c" is generated as output for the original include file, "/dev/headers/myvars.qc."
Including Source Code with Labels
Some EQUEL statements generate labels in the output code. If you include a file containing such statements, you must be careful to include the file only once in a given C scope. Otherwise, you may find that the compiler later issues C warning or error messages to the effect that the generated labels are defined more than once in that scope.
The statements that generate labels are the retrieve statement and all the EQUEL/FORMS block-type statements, such as display and unloadtable.
Last modified date: 04/03/2024