The Order in which Compiler Directives are Processed

Compiler directives can be specified using more than one method. During compilation, they are processed in a particular order according to the method in which they have been specified.

The Compiler processes directives specified on the command line from left to right. If a directive appears more than once, the Compiler uses the setting that it processed last for that directive.

The Compiler processes directives in the following order:

  1. Directives contained within the system-wide directives file cobol.dir.
    Note: If NOCOBOLDIR is set anywhere, the directives in this file are not processed.
  2. Directives contained within the common directives file, directives.mf.
  3. On the command line, system default directives contained in cob options in the file $COBDIR/etc/cobopt .
  4. On the command line, user default directives contained in cob options in the environment variable COBOPT .
  5. The IDE applies the DIALECT directive specified in the project properties.
    Note: This can result in other directives being applied. See DIALECT in the Compiler Directives chapter for more information.
  6. From within the IDE, directives set in the project, build configuration, folder, and then file properties, or on the command line, Compile-time directives specified in the cob command.
  7. Directives set via the $SET statement within the source code.

    In addition, you can set directives in a user directives file, which you specify with the USE directive; these are processed when they are encountered.

The above order means that, for example, a directive set using a $SET statement would override the setting for that directive that has been set in the project properties.