fglcomp

The fglcomp tool compiles .4gl source files into .42m p-code modules, and does various other tasks.

Syntax 1: Compiling .4gl sources

fglcomp [comp-options] [prepro-options] file-list
  1. comp-options are described in compilation options.
  2. prepro-options are described in preprocessor options.
  3. In this form, fglcomp can handle several .4gl sources files as arguments, see file-list.
where file-list is:
{ { module[.4gl]
    | pattern
    } [...]
| @argfile
}
  1. module.4gl is a source file to compile. The .4gl extension is optional.
  2. pattern is a MATCHES-style pattern to find files, like '[a-z]*.4gl'.
  3. argfile defines a file that contains a list of .4gl sources to be compiled. Each line must specify a filename or a pattern.

Syntax 2: Building documentation

fglcomp --build-doc [doc-options] [prepro-options] module[.4gl]
  1. doc-options are described in documentation options.
  1. prepro-options are described in preprocessor options.
  2. module.4gl is a source file to compile. The .4gl extension is optional.

Syntax 3: Extracting localized strings

fglcomp -m [prepro-options] module[.4gl]
  1. module.4gl is a source file to compile. The .4gl extension is optional.
  2. prepro-options are described in preprocessor options.
  3. In this form, fglcomp extracts localized strings from the source.

Syntax 4: Source code formatting

fglcomp --format [format-options] module[.4gl]
  1. format-options can be any of the formatting options.
  2. module.4gl is a source file to compile. The .4gl extension is optional.

Syntax 5: Add imported module prefixes

fglcomp --qualify-imports [prepro-options] module[.4gl]
  1. prepro-options are described in preprocessor options.
  2. module.4gl is a source file to compile. The .4gl extension is optional.

Syntax 6: Show dependencies

fglcomp --dependencies [prepro-options] file-list
  1. prepro-options are described in preprocessor options.
  2. In this form, fglcomp can handle several .4gl sources files as arguments, see file-list.

Syntax 7: Information options

fglcomp info-option
  1. info-option can be any of the informational options.

Options

Table 1. Compilation options
Option Description
-M Write error messages to standard output instead of creating a .err error file.
--make Do not recompile .42m modules up-to-date with provided .4gl source. See Compiling in make mode.
--simulate Print the list of .4gl sources that would be compiled (can be used with or without --make). See Compiling in make mode.
-W warning-argument Produce warning messages.

The warning argument can be used as follows:

  • -W all enables all warning flags.
  • -W error makes the compiler stop, if any warning is raised, as if an error occurred.
  • -W to-err-file writes warnings to the .err file when this file is produced. By default warnings go to the stderr stream.
  • -W unused displays a message for all unused symbols.
  • -W unused-parameter displays a message for all unused function parameters.
  • -W return displays a warning if the same function returns different number of values with several RETURN statements.
  • -W stdsql displays a message for all non-portable SQL statements or language instructions.
  • -W print displays a message when the PRINT instruction is used outside a REPORT.
  • -W implicit warns on references to undeclared functions. A function is undeclared if not defined in the current module or in any imported module.
  • -W apidoc prints a warning for invalid source documentation tags when using the --build-doc option.
The -W option also supports the negative form of arguments by using the no- prefix as in: no-return, no-unused, no-stdsql. You might need to use these negative forms in order to disable some warning when using the -W all option:
fglcomp -Wall -Wno-stdsql customers.4gl

Switches will be enabled/disabled in the order of appearance in the command line.

--timestamp Add compilation timestamp to build information in 42m header. See 42m module information.
--omit-source-name Omit the source file name in the build information of the 42m header. See 42m module information.
--tag=string Write a custom string in the build information of the 42m header. See 42m module information.
--build-rdd While compiling, generate the module.rdd Report Data Definition file (of REPORT routines).
--verbose Print detailed compilation information.
--implicit=type Specify whether or not to compile imported modules, if the .42m does not exist, or if the .4gl source is more recent as the .42m.

Here type can be one of:

-r or --resolve-calls

Throw an error on references to undeclared functions. Each external function must be made known to the compiler by IMPORT FGL. When using this option, the linking phase is no longer needed; a source (.4gl) file compiled with this option must not be linked. See IMPORT FGL module for more details.

--java-option=option

Passes Java runtime options when initializing the JNI interface.

See Java Interface for more details.

-S With this option, fglcomp extracts all Static SQL commands from the source while compiling the source code.
Table 2. Focumentation options
Option Description
--doc-private When using the --build-doc option, include PRIVATE symbols to the documentation.
Table 3. Formatting options
Option Description
--fo-align-consecutive-assignments={0|1} Aligns equal signs of consecutive variable assignments. Default is 0 (no alignment)
--fo-align-consecutive-types={0|1} Aligns type specification of consecutive variable definitions. Default is 0 (no alignment)
--fo-align-trailing-comments={0|1} Aligns consecutive comments. Default is 0 (no alignment)
--fo-inplace Write formatted output back to the provided file, instead of stdout. Creates a copy of the original file in filename.4gl~
--fo-fallback-style=filename Specify the configuration filename to be used if no .fgl-format file is found.
--fo-continuation-indent-width=integer Define the source line width limit. Default is 80.
--fo-column-limit=integer Number of columns to use for indentation. Default is 4.
--fo-indent-width=integer Indent width for line continuations. Default is 4.
--fo-label-indent={0|1} When 1, indent instruction clauses such as WHEN in a CASE instruction. Default is 1 (enabled).
--fo-pack={0|1} When 1, try to put as many items on the same line as possible. When 0, use one line for each item. Default is 0 (do not pack).
--fo-lowercase-keywords={0|1} When 1, produce lowercase keywords. When 0, produce uppercase keywords. Default is 0 (uppercase).
--fo-use-tab={0|1} When 1, instead of using space characters all over for column indentation (the default), use tabs to fill whitespace that spans at least from one tab stop to the next one, based on --fo-tab-width and --fo_indent-width.
--fo-tab-width=integer Defines the number of columns used for tab stop, when --fo-use-tab is specified. The default is 8 columns.
--fo-lines=start-line:end-line Formats only the range of lines specified. This option can be used multiple times to specify several pieces of code to be reformatted.
Table 4. Preprocessor options
Option Description
-E Preprocess only. See Source preprocessor for more details.
-p option

Preprocessing control, where option can be one of:

  • nopp: Disable preprocessing.
  • noli: No line number information (only with -E option).
  • fglpp: Use # syntax instead of & syntax.
  • auto: Detect # syntax or & syntax automatically.
-I path Provides a single path to search for include files. See Source preprocessor for more details.
-D ident[=value] Defines the macro 'ident' with an optional value (default is 1). See Source preprocessor for more details.
-U ident Undefines the macro 'ident'. See Source preprocessor for more details.
Table 5. Informational options
Option Description
-V or --version Displays version information.
-h or --help Displays options for the tool.
-i [ mbcs ] Displays information about the current locale / character set settings. See Application locale.

Usage

The fglcomp command line tool compiles a .4gl into a .42m p-code module:
fglcomp customers.4gl

If a compilation error occurs, the compiler generates an error file with an .err extension. The error file contains the original source code with error messages. Use the option -M to display the error messages to standard error instead of producing the .err file.