Programming tools / Compiling source files |
Source code modules (with .4gl file extension) must be compiled to p-code modules (with .42m file extension) by using the fglcomp tool. Compiled p-code modules are independent from the platform and processor architecture.
The following lines show a compilation in a UNIX™ shell session:
$ cat prog.4gl MAIN DISPLAY "hello" END MAIN $ fglcomp prog.4gl $ ls -s prog.42m 4 prog.42m
If an error occurs, the compiler writes an error file with the .err extension.
$ cat prog.4gl MAIN LET x = "hello" END MAIN $ fglcomp prog.4gl Compilation was not successful. Errors found: 1. The file prog.4gl has been written. $ cat prog.err MAIN LET x = "hello" | The symbol 'x' does not represent a defined variable. | See error number -4369. END MAIN
With the -M option, you can force the compiler to display an error message instead of generating an .err error file:
$ fglcomp prog.4gl xx.4gl:2:8 error:(-4369) The symbol 'x' does not represent a defined variable.
By default, the compiler does not raise any warnings. You can turn on warnings with the -W option:
$ cat prog.4gl MAIN DATABASE test1 SELECT COUNT(*) FROM x, OUTER(y) WHERE x.k = y.k END MAIN $ fglcomp -W stdsql prog.4gl xx.4gl:3: warning: SQL statement or language instruction with specific SQL syntax.
When a warning is raised, you can use the -W error option to force the compiler to stop as if an error was found. For more details about the -W option, see Arguments for the -W option.
$ fglcomp --verbose main.4gl [parsing main.4gl] [compiling: fglcomp --import-by=main --verbose mod1] [parsing mod1.4gl] [compiling: fglcomp --import-by=main,mod1 --verbose mod2] [parsing mod2.4gl] [writing mod2.42m] [loading mod2.42m] [writing mod1.42m] [loading mod1.42m] [writing main.42m]