A rich set of XDS compiler options allows you to control the source language, the generated code, and the internal limits and settings. We distinguish between boolean options (or just options) and equations. An option can be set ON (TRUE) or OFF (FALSE), while an equation value is a string.
Options control the process of compilation, including language extensions, run-time checks and code generation. An option can be set ON (TRUE) or OFF (FALSE).
A compiler setup directive (See Options) is used to set the option value or to declare a new option.
Options may be set in a configuration file, on the command line, in a project file). or in the source text (See Source code directives). At any point of operation, the last value of an option is in effect.
Alphabetical list of all options along with their descriptions may be found in the section Options reference.
Table 1. Run-time checks
Option | Meaning |
ASSERT | enable ASSERT generation |
CHECKDINDEX | check of dynamic array bounds |
CHECKDIV | check for a positive divisor |
(DIV and MOD) | |
CHECKINDEX | check of static array bounds |
CHECKNIL | NIL pointer dereference check |
CHECKPROC | check of a formal procedure call |
CHECKRANGE | range checks |
(range types and enumerations) | |
CHECKSET | range check of set operations |
CHECKTYPE | dynamic type guards (Oberon-2 only) |
COVERFLOW | cardinal overflow check |
IOVERFLOW | integer overflow check |
Table 2. Source language control options
Option | Meaning |
M2ADDTYPES | add SHORT and LONG types |
M2BASE16 | use 16-bits basic types in Modula-2 |
M2CMPSYM | compare symbol files in Modula-2 |
M2EXTENSIONS | enable Modula-2 extensions |
O2ADDKWD | enable additonal keywords in Oberon-2 |
O2EXTENSIONS | enable Oberon-2 extensions |
O2ISOPRAGMA | enable ISO Modula-2 pragmas in Oberon |
O2NUMEXT | enable Oberon-2 scientific extensions |
STORAGE | enable default memory management in Modula-2 |
??? | enable Topspeed Modula-2-compatible extensions |
Table 3. Code generator control options
Option | Meaning |
__GEN_C__ | ANSI C code generation |
__GEN_X86__ | code generation for 386/486/Pentium/PentiumPro |
DBGNESTEDPROC | generate information about procedure nesting |
DBGQUALIDS | generate qualified identifiers in debug info |
DEFLIBS | put the default library names into object files |
DOREORDER | perform instruction scheduling |
GENASM | generate assembly text |
GENCPREF | generate underscore prefixes |
GENDEBUG | generate code in the debug mode |
GENFRAME | always generate a procedure frame |
GENHISTORY | enable postmorten history |
GENPTRINIT | generate a local pointer initialization |
LINENO | generate line numbers in object files |
NOHEADER | disable generation of a header file |
NOOPTIMIZE | disable machine-independent opimizations |
NOPTRALIAS | ignore pointer aliasing |
ONECODESEG | generate one code segment |
PROCINLINE | enable in-line procedure expansion |
SPACE | favor code size over speed |
VERSIONKEY | append version key to the module initialization |
VOLATILE | declare variables as volatile |
Table 4. Miscellaneous options
Option | Meaning |
BSCLOSURE | browse control option |
BSREDEFINE | browse control option |
CHANGESYM | permission to change a symbol file |
FATFS | limit file names to 8.3 |
GCAUTO | enables implicit call of the garbage collector |
LONGNAME | use long names in batch files |
M2 | force the Modula-2 compiler |
MAIN | mark an Oberon-2 main module |
MAKEDEF | generate definition |
MAKEFILE | generate makefile |
O2 | forces the Oberon-2 compiler |
OVERWRITE | create a file, always overwrites the old one |
VERBOSE | produce verbose messages |
WERR | treat warnings as errors |
WOFF | suppress warning messages |
XCOMMENTS | preserve exported comments |
This section lists all options in alphabetical order. Those options that may be arbitrarily placed in the source code are marked as inline options (See also Source code directives). There are also options which can be placed in a source file, but only in a module header (i.e. before any of the keywords "DEFINITION", "IMPLEMENTATION", and "MODULE") These options are marked as header. If an option is not marked either as header or inline, then the result of setting it in the source text is undefined.
Operation modes in which an option has effect are listed in square brackets ([]) after the option name; the character '*' stands for all operation modes. For example, [browse] means that the option is used by the compiler in the BROWSE operation mode only.
Note: in the MAKE and PROJECT modes the compiler switches to the COMPILE mode to compile each module.
Run-time check options are ON by default. If not explicitly specified, other options are OFF (FALSE) by default.
The compiler sets this option ON, if the code generation for 386/486/Pentium/PentiumPro is in operation.
The option can be used for compiling different text fragments for different targets. See also Conditional compilation.
The compiler sets this option ON, if the C code generation is in operation.
The option can be used for compiling different text fragments for different targets. See also Conditional compilation.
If the option is OFF, the compiler ignores all calls of the standard procedure ASSERT.
Warning: Ensure that all ASSERT calls in your program do not have side effects (i.e. do not contain calls of other function procedures) before setting this option OFF.
The option is ON by default.
Include all visible methods.
If the option is set ON, the browser includes all defined and inherited type-bound procedure declarations with all record declarations when creating a pseudo-definition module. See also Creating a definition.
Include all redefined methods.
If the option is set ON, the browser includes original definitions of any overwritten type-bound procedures with record declarations. See also Creating a definition.
Permission to change a module interface (a symbol file).
The Oberon-2 compiler creates a temporary symbol file every time an Oberon-2 module is compiled, compares this symbol file with the existing one and overwrites it with the new one if necessary. When the option is OFF (by default), the compiler reports an error if interface of a module (and, hence, its symbol file) has been changed and does not replace the old symbol file.
Note: if the M2CMPSYM option is set, the same is valid for compilation of a Modula-2 definition module, i.e., the CHANGESYM option should be set ON for the compilation to succeed if a module interface has been changed.
A check of dynamic array bounds.
If the option is set ON, the compiler generates index checks for dynamic arrays (POINTER TO ARRAY OF T).
The option is ON by default.
If the option is set ON, the compiler generates a check if a divisor is positive in DIV and MOD operators.
The option is ON by default.
A check of static array bounds.
If the option is set ON, the compiler generates index checks for all arrays except dynamic (See the CHECKDINDEX option).
The option is ON by default.
If the option is set ON, the compiler generates NIL checks on all pointer dereferences.
The option is ON by default.
If the option is set ON, the compiler generates a NIL check when calling a procedure variable.
The option is ON by default.
If the option is set ON, the compiler generates range checks for range types and enumerations.
The option is ON by default.
If the option is set ON, the compiler generates range checks for set operations (INCL, EXCL, set aggregates).
The option is ON by default.
If the option is set ON, the compiler generates dynamic type guards.
The option is ON by default.
If the option is set ON, the compiler generates overflow checks for all cardinal (unsigned) arithmetic operators.
The option is ON by default.
If this option is set ON, the compiler includes procedure nesting data into debug information (CodeView and HLL formats only, see the DBGFMT equation).
This is a non-standard feature, so a third party debugger would not work correctly with an executable compiled with DBGNESTEDPROC ON. For instance, MSVC does not display local variables of nested procedures.
This option is OFF by default.
If the option is set ON, the compiler prefixes names of Modula-2/Oberon-2 global variable with the name of the respective module and underscore in debug information. This feature may help you distingushing identically named exported variables from different modules in third-party debuggers that do not support Modula-2/Oberon-2.
This option is OFF by default.
If the option is set ON, the compiler writes the default library names to the generated object files.
The option is ON by default.
Setting this option ON enables the instruction scheduling mechanism of the x86 code generator. It reorders CPU instructions so that independent instructions can be executed simultaneously whenever possible.
Note: this optimization significantly slows down the compiler, but results in a code perfomance gain of 5-15%.
Forces the compiler to limit file names to FAT "8.3" convention.
Enables implicit calls of the garbage collector in the generated program. The option is ignored for all modules except the top-level module of the program. We recommend to set the option in the project or configuration file.
See also Memory management.
If this option is set ON, the compiler generates text in the assembly language instead of object files. The only assembler supported in the current version is GNU Assembler.
If the option is set ON, the compiler uses underscore as a prefix for all public names in object files.
If the option is set ON, the compiler puts debug information into an object file.
In some cases, switching the option ON may reduce code quality.
See also the DBGFMT equation.
If the option is set ON, the compiler always generates a stack frame. It may be necessary to simplify debugging.
If the option is set ON, the run-time system prints a stack of procedure calls (a file name and a line number) on abnormal termination of your program. It should be set when compiling a main module of the program. In this case the required part of the run-time system will be added to the program. The option LINENO should be set for all modules in the program.
See Debugging a program for an example.
Note: In some cases the printed list may contain incorrect lines, i.e. procedures that were not called in the given context (See Postmortem history).
If the option is set ON, the compiler generates code for initialization of all local pointers, including variables, record fields and array elements. Values of all non-pointer record fields and array elements are undefined.
The option is ON by default.
If the option is set ON, the compiler generates overflow checks of all integer (signed) arithmetic operators.
The option is ON by default.
If the option is set ON, the compiler inserts line number information into object files. This option should be set ON to get the postmortem history (See the GENHISTORY option) and for debugging.
Use long names.
If the option is set ON, the compiler uses full path as a prefix for all module names in the generated batch files. See also BATCH submode.
Force the Modula-2 compiler.
If the option is set ON, the Modula-2 compiler is invoked regardless of file extension. The option is ignored in MAKE and PROJECT modes.
Add short and long modifications of whole types.
If the option is set ON, the compiler recognizes the types SHORTINT, LONGINT, SHORTCARD and LONGCARD as pervasive identifiers .
Warning: Usage of additional types may cause problems with the software portability to other compilers.
If the option is set ON, the basic types INTEGER, CARDINAL, and BITSET are 16 bits wide in Modula-2. By default, they are 32 bits wide.
If the option is set ON, the Modula-2 compiler compares the symbol file generated for a definition module with the old version exactly as the Oberon-2 compiler does. If the symbol files are equal, the old one is preserved, otherwise the compiler overwrites symbol file, but only if the CHANGESYM option is set ON.
If the option is set ON, the compiler allows XDS Modula-2 language extensions, such as line comment ("--"), read-only parameters, etc., to be used in the source code.
Warning: Extensions usage may cause problems with porting to third-party compilers.
Mark the Oberon-2 main module.
If the option is set ON, the compiler generates a program entry point (`main' function) for the Oberon-2 module (See Program structure). Recommended to be used in a module header.
Forces the Oberon-2 compiler to generate a (pseudo-) definition module after successful compilation of an Oberon-2 module. The compiler preserves the so-called exported comments (i.e. comments started with `(**') if the XCOMMENTS option is set ON.
Forces the compiler to generate a makefile after successful compilation of a project. See also GEN mode and Template files.
This option is used by translators to C. Native code compilers recognize but ignore it.
If the option is set ON, the compiler assumes that there is no pointer aliasing, i.e. there are no pointers bounded to non-structure variables. The only way to get a pointer to a variable is to use the low-level facilities from the module SYSTEM. We recommend to turn this option ON for all modules except low-level ones. Note: the code quality is better if the option is ON.
Force Oberon-2 compiler.
If the option is set ON, the Oberon-2 compiler is invoked regardless of the file extension. The option is ignored in MAKE and PROJECT modes.
Allows Modula-2 exceptions and finalization to be used in Oberon-2 programs, adding keywords EXCEPT, RETRY, and FINALLY.
Warning: Usage of this extension will prevent your program from porting to other Oberon-2 compilers.
If the option is set ON, the compiler allows Oberon-2 language extensions to be used (See Language extensions).
Warning: Extensions usage will affect portability to third-party Oberon-2 compilers.
If the option is set ON, the compiler allows the ISO Modula-2 style pragmas <* *> to be used in Oberon-2. See Source code directives and Source code directives.
Warning: Usage of ISO Modula-2 pragmas may cause problems when porting source code to third-party Oberon-2 compilers.
If the option is set ON, the compiler allows the Oberon-2 scientific language extensions to be used (See Language extensions), including COMPLEX and LONGCOMPLEX types and the in-line exponentiation operator.
Warning: Usage of additional types may cause problems with portability to other compilers.
If the option is ON, the compiler produces only one code segment which contains all code of a module, otherwise it generates a separate code segment for each procedure.
Warning: Setting this option ON disables smart linking.
The option changes the way the compiler selects a directory for output files. If the option is OFF, the compiler always creates a file in the directory which appears first in the search path list correspondent to a pattern matching the file name. Otherwise, the compiler overwrites the old file, if it does exist in any directory of that list. See also Redirection file.
If the option is ON, the compiler tries to expand procedures in-line. In-line expansion of a procedure eliminates the overhead produced by a procedure call, parameter passing, register saving, etc. In addition, more optimizations become possible because the optimizer may process the actual parameters used in a particular call.
A procedure is not expanded in-line under the following circumstances:
If the option is set ON, the compiler performs optimizations to produce smaller code, otherwise (by default) to produce faster code.
If the option is set ON, the compiler uses the default memory allocation and deallocation procedures for the standard procedures NEW and DISPOSE.
Warning: Usage of this option may cause problems with software portability to other compilers.
If the option is set ON, the compiler will report a reason for each module (re)compilation (See Smart recompilation).
This option may be used to perform version checks at link time. If the option is set ON, the compiler generates a name of a module body as composition of
If the option is OFF, the compiler generates module body names in a form: <module_name>_BEGIN.
Note: the option should be set when compiling a Modula-2 definition module or an Oberon-2 module.
If this option appears to be switched ON during compilation of a variable definition, the compiler will assumes that references to that variable may have side effects or that the value of the variable may change in a way that can not be determined at compile time. As a result, the optimizer will not eliminate any operation involving that variable, and changes to the value of the variable will be stored immediately.
When the option WERRnnn (e.g. WERR301) is set ON, the compiler treats the warning nnn (301 in the above example) as error. See the xc.msg file for warning texts and numbers.
-WERR+ forces the compiler to treat all warnings as errors.
When the option WOFFnnn (e.g. WOFF301) is set ON, the compiler does not report the warning nnn (301 in the above example). See the xc.msg file for warning texts and numbers.
-WOFF+ disables all warnings.
If the option is set ON, the browser includes so-called exported comments (i.e. comments which start with "(**") into a generated pseudo definition module.
See also Creating a definition.
An equation is a pair (name,value), where value is in general case an arbitrary string. Some equations have a limited set of valid values, some may not have the empty string as a value.
A compiler setup directive (See Options) is used to set an equation value or to declare a new equation.
Equations may be set in a configuration file, on the command line and in a project file). Some equations may be set in the source text, at an arbitrary position (marked as inline in the reference), or only in the module header (marked as header). At any point of operation, the most recent value of an equation is in effect.
Alphabetical list of all equations may be found in the section Equations reference.
Table 5. File extensions
Name | Default | File type |
BATEXT | .bat | recompilation batch file |
BSDEF | .odf | pseudo-definition file created by browser |
CODE | .o | object file |
DEF | .def | Modula-2 definition module |
MKFEXT | .mkf | makefile |
MOD | .mod | Modula-2 implementation or main module |
OBERON | .ob2 | Oberon-2 module |
OBJEXT | .o | object file |
PRJEXT | .prj | project file |
SYM | .sym | symbol file |
Table 6. Code generator equations
Name | Default | Meaning |
ALIGNMENT | 4 | data alignment (please read details below) |
CC | GCC | C compiler compatibility |
CODENAME | _TEXT | Code segment name |
CPU | GENERIC | CPU to optimize for |
DATANAME | _DATA | data segment name |
DBGFMT | see desc. | debug information format |
ENUMSIZE | 4 | default size of enumeration types |
GCTHRESHOLD | garbage collector threshold (obsolete) | |
HEAPLIMIT | 0 | generated program heap limit |
MINCPU | 386 | CPU required for execution |
OBJFMT | ELF | object file format |
SETSIZE | 4 | default size of small set types |
STACKLIMIT | 0 | generated program stack limit |
Table 7. Miscellaneous equations
Name | Default | Meaning |
ATTENTION | ! | attention character in template files |
BATNAME | out | batch file name |
BATWIDTH | 128 | maximum line width in a batch file |
BSTYLE | DEF | browse style (See Creating a definition) |
COMPILERHEAP | heap limit of the compiler | |
COMPILERTHRES | compiler's garbage collector threshold (obsolete) | |
DECOR | hrtp | control of compiler messages |
ERRFMT | See Error message format specification | error message format |
ERRLIM | 16 | maximum number of errors |
FILE | name of the file being compiled | |
LINK | linker command line | |
LOOKUP | lookup directive | |
MKFNAME | makefile name | |
MODULE | name of the module being compiled | |
PRJ | project file name | |
PROJECT | project name | |
TABSTOP | 8 | tabulation alignment |
TEMPLATE | template name (for makefile) |
Operation modes in which an equation has effect are enclosed in square brackets ([]) after the equation name; the character '*' stands for all operation modes. For example [browse] means that the equation is used by the compiler in the BROWSE operation mode only. Note: the compiler switches from the MAKE and PROJECT mode to the COMPILE mode to compile a module.
This equation sets the data alignment. Valid values are: 1,2,4, or 8. See Record types for further details.
Warning: Since XDS libraries are built through GCC which uses 4 byte alignment, you should always keep ALIGNMENT set to 4, unless you exactly know what you are doing. See Configuring XDS for a C Compiler for more details.
The equation defines an attention character which is used in template files ("!" by default). See Template files.
Sets the file extension for recompilation batch files (by default .bat). See BATCH submode.
Sets the batch file name.
The name of the project file will be used if no batch file name is explicitly specified. See BATCH submode.
Sets the maximum width of a line in a generated batch file (by default 128). See BATCH submode.
Sets the file extension for pseudo-definition modules created by the browser (by default .odf). See BROWSE mode.
Sets the style of generated pseudo-definition modules. See Creating a definition.
Sets the C compiler compatibility mode. The correspondent calling and naming conventions will be used for procedures and variables declared as ["C"].
Currently the only valid value on Linux is "GCC".
If the value of the equation is undefined, "GCC" is assumed.
See Configuring XDS for a C Compiler for more details.
Sets the file extension for code files generated by the compiler (by default .o).
Sets name for a code segment.
This equation is left for compatibility; it is ignored by the compiler. In versions prior to 2.50, it was used to fine tune the compiler's garbage collector.
See also XDS memory usage.
Sets the maximum amount of heap memory (in bytes), that can be used by the compiler. For systems with virtual memory, we recommend to use a value which is less than the amount of physical memory.
Setting this equation to zero forces adaptive compiler heap size adjustment according to system load.
Specifies on which Intel x86 family representative the resulting program will be executed optimally.
Valid values: "386", "486", "PENTIUM", and "PENTIUMPRO". The value must be "greater of equal" than the value of the MINCPU equation.
There is also the special value "GENERIC", which means that the optimizer should not perform code transformations that may significantly reduce performance on a particular CPU.
Sets name for a data segment.
Sets debug information format for output object files. Valid values are "CodeView" and "HLL".
The equation controls output of the xc utility. The value of equation is a string that contains any combination of letters "h", "t", "r", "p" (capital letters are also allowed). Each character turns on output of
By default, the equation value is "hrt".
Sets the file extension for Modula-2 definition modules (by default .def).
Sets the default size for enumeration types in bytes (1,2, or 4). If an enumeration type does not fit in the current default size, the smallest suitable size will be taken.
A symbolic name of the host platform.
This equation is always set to a symbolic name of the target platform (CPU/operating system).
Sets the error message format. See Error message format specification for details.
Sets the maximum number of errors allowed for one compilation unit (by default 16).
The compiler sets this equation to the name of the currently compiled file. See also the MODULE equation.
This equation is left for compatibility; it is ignored by the compiler. In versions prior to 2.50, it was used to fine tune the garbage collector.
See also Memory management.
Sets the maximum amount of heap memory, that can be allocated by the generated program. The value is set in bytes.
Setting this equation to zero enables the run-time system to dynamically adjust heap size according to application's memory demands and system load.
The equation should be set when the top-level module of the program is compiled. We recommend to set it in a project file or the configuration file.
See also Memory management.
Defines a command line, which will be executed after a successful completion of a project. As a rule, the equation is used for calling a linker or make utility.
See Building a program for examples.
Syntax:
-LOOKUP = pattern = directory {";" directory }
The equation can be used for defining additional search paths that would complement those set in the redirection file. A configuration or project file may contain several LOOKUP equations; they are also permitted on the command line.
See also Redirection file and Project files.
Specifies an Intel x86 family representative which (or higher) is requried for the resulting program to be executed.
Valid values: "GENERIC", "386", "486", "PENTIUM", and "PENTIUMPRO". For this equation, "GENERIC" is equivalent to "386". The value of the CPU equation must be "greater of equal" than the value of this equation.
Sets the file extension for generated makefiles (by default .mkf). See GEN mode.
Sets the name for a generated makefile. See GEN mode.
Sets the file extension for Modula-2 implementation and program modules (by default .mod).
The compiler sets this equation to the name of the currently compiled module. See also the FILE equation.
Sets the file extension for Oberon-2 modules (by default .ob2).
Sets the file extension for object files (by default .o).
Sets format for output object files. Valid values are "OMF", "COFF" and "ELF".
In the COMPILE and MAKE operation modes, the equation defines a project file to read settings from. In the PROJECT mode, the compiler sets this equation to a project file name from the command line. See PROJECT mode.
Sets the file extension for project files (by default .prj). See PROJECT mode.
If a project file name is defined, the compiler sets the equation to a project name without a file path and extension. For example, if the project file name is prj/Work.prj, the value of the equation is set to Work. The equation may be used, for instance, in a template file to set the name of the executable file.
Sets the default size for small (16 elements or less) set types in bytes (1,2, or 4). If a set type does not fit in the current default size, the smallest suitable size will be taken.
Sets the maximum size of the stack in a generated program. The value is set in bytes.
The equation should be set when a top-level module of a program is compiled. We recommend to set the option in the project or configuration file.
Note: for some linkers the stack size should be also set as a linker option.
Sets the file extension for symbol files (by default .sym). See Files generated during compilation.
When reading text files, the compiler replaces the ASCII TAB character with the number of spaces required to align text (by default TABSTOP is equal to 8). A wrong value may cause misplaced comments in a generated pseudo-definition module, incorrect error location in an error message, etc. We recommend to set this equation to the number used in your text editor.
Sets a name of a template file. See Template files.
The format in which XDS reports errors is user configurable through the ERRFMT equation. Its syntax is as follows:
{ string "," [ argument ] ";" }
Any format specification allowed in the C procedure printf can be used in string.
Argument | Type | Meaning |
line | integer | position in a source text |
column | integer | position in a source text |
file | string | name of a source file |
module | string | module name |
errmsg | string | message text |
errno | integer | error code |
language | string | Oberon-2 or Modula-2 |
mode | string | ERROR or WARNING or FAULT |
utility | string | name of an utility |
Argument names are not case sensitive. By default, the error message format includes the following clauses:
"(%s",file; | --- | a file name |
"%d",line; | --- | a line number |
",%d",column; | --- | a column number |
") [%.1s] ",mode; | --- | the first letter of an error mode |
"%s\n",errmsg; | --- | an error message |
If a warning is reported for the file test.mod at line 5, column 6, the generated error message will look like this:
(test.mod 5,6) [W] variable declared but never used
The system module COMPILER provides two procedures which allow you to use compile-time values of options and equations in your Modula-2 or Oberon-2 program:
PROCEDURE OPTION(<constant string>): BOOLEAN; PROCEDURE EQUATION(<constant string>): <constant string>;
Both this procedures are evaluated at compile-time and may be used in constant expressions.
Note: The COMPILER module is non-standard.
Printf.printf("This program is optimized for the %s CPU\n", COMPILER.EQUATION("CPU")); IF COMPILER.OPTION("__GEN_C__") THEN ... END;