THE DAILY DIGEST

The daily edition.

Essential reading from Rocket Enterprise. Straight to the source.

Archived edition
DAILY EDITION1 story· 4 min read
IN FOCUS

Compiler Directive Precedence: The 7-Layer Evaluation Order, Left-to-Right Rules, and $SET Scoping

In Rocket Enterprise Developer 12.0 for Linux/UNIX, the COBOL compiler evaluates directives across a strict seven-tier hierarchy: cobol.dir (bypassable via NOCOBOLDIR), directives.mf, system cobopt, user COBOPT, IDE DIALECT, command-line arguments (evaluated left-to-right), and source-level $SET statements. Because later layers override earlier ones, $SET in column 7 takes ultimate precedence for syntax-check directives. However, dialect directives must be set in initial $SET statements, and code generation directives cannot be specified via $SET. [1] [2] [3] [4]

Read the full briefing

Scope and Architectural Overview

This article covers compiler directive resolution order, configuration layers, and scoping rules in Rocket Enterprise Developer / Enterprise Server 12.0 for Linux/UNIX.

In enterprise COBOL development, compiler directives dictate crucial compilation behaviors—ranging from reserved word sets and language dialects (e.g. DIALECT"ENTCOBOL") to data format representations and code generation optimizations. Because directives can be specified in environment variables, configuration files, IDE project properties, and source code, understanding directive precedence is essential to diagnose unexpected compilation behavior, dialect conflicts, and build failures.

The 7-Tier Precedence Order

As documented in The Order in Which Compiler Directives Are Processed, the Rocket COBOL compiler processes directives across seven distinct levels, where later levels override conflicting settings established by earlier ones:

  1. System-Wide Directives File (cobol.dir): Evaluates global installation directives first.
  2. Common Directives File (directives.mf): Applies project-level shared directives.
  3. System Default Options ($COBDIR/etc/cobopt): Processes system-level command-line flags and directives.
  4. User Environment Options (COBOPT): Processes user-specific environment variables for the cob command.
  5. IDE Project Dialect: Evaluates the DIALECT directive configured in project properties (which can inject dependent secondary directives).
  6. Command-Line Directives / IDE File Properties: Directives passed via the cob command line or defined in IDE project, build configuration, and folder properties.
  7. Source-Level $SET Statements: Embedded directly inside the COBOL program source code.

Within any single command-line invocation, directives are processed strictly from left to right; if a directive appears multiple times, the rightmost specification takes effect.

System-Wide Files and the NOCOBOLDIR Override

System administrators can enforce base compiler standards across an organization using the System-wide Directives File, cobol.dir.

The compiler looks for cobol.dir first in the current working directory, and then in $COBDIR/etc/cobol.dir. Directives inside this file can be separated by newlines, spaces, colons, or semicolons.

Critical Operational Nuance: If NOCOBOLDIR is specified anywhere—on the command line, in an environment variable, or in a higher-level configuration file—the compiler completely bypasses reading cobol.dir. Furthermore, if the compiler encounters an invalid or unrecognized directive in a directives file, compilation immediately terminates with a "Rejected" error.

Command-Line Processing and COBOPT

Outside the IDE, command-line builds frequently configure options through the COBOPT Environment Variable.

COBOPT defines options that supplement or override $COBDIR/etc/cobopt. It can route directives specifically to the syntax-check phase (-C) or the code generation phase (-N):

# Set syntax check and code generation options in COBOPT
export COBOPT='-C "COPYEXT=CPY,cpy NOOPTIONAL-FILE" -N "nobound"'

Multiple options and environment settings can be packaged within COBOPT. Directives specified explicitly on the cob command line (e.g. cob -C "LIST" ) supersede conflicting flags inherited from COBOPT.

Source-Level $SET Scoping and Phase Restrictions

As detailed in $SET Statements in the Source Code, $SET statements provide program-level overrides that take ultimate precedence over all preceding configuration files, environment variables, and project properties.

Using $SET requires adherence to strict structural rules:

  1. Formatting Rules: The $ character must reside in column 7. A $SET statement cannot be continued onto a subsequent line and must not end with a period.
  2. Phase Limitation: Directives specified in a $SET statement can belong only to the syntax-check phase. Directives belonging to the generate phase (such as BOUND or NOBOUND) cannot be specified via $SET and will be rejected.
  3. Initial vs. Dynamic Placement:
    • Initial $SET Statements: Must appear before any COBOL division headers or code statements. Dialect-controlling directives (such as DIALECT or SOURCEFORMAT) must be defined on an initial $SET statement and cannot be unset or changed later in the program.
    • Dynamic $SET Statements: Statements placed after initial headers take effect from that line forward, enabling localized scoping (for instance, turning data compression on for a specific SELECT clause and immediately resetting it with $SET NODATACOMPRESS).

Documentation Takeaway

In Rocket Enterprise Developer 12.0 for Linux/UNIX, compiler directives follow a deterministic seven-tier hierarchy where source-level $SET statements in column 7 override command-line options, COBOPT, and cobol.dir; developers must place dialect directives in initial $SET statements before division headers, keep code-generation directives out of $SET statements, and recognize that NOCOBOLDIR suppresses system-wide directive inheritance.

Rocket Enterprise Developer / Enterprise Server 12.0 for Linux/UNIX
Documentation references
That’s the briefing.You’ve reached the end of this edition.
More editions

From the archive

View all
Nov 1

LOCAL-STORAGE vs THREAD-LOCAL-STORAGE: Lifetime Is the Real Choice

Nov 1

Security Tracing in Enterprise Server: Three Output Targets, Two Configuration Scopes, and a Production Warning

Nov 1

CICS Transaction Security: RLS and CMDSEC Are Per-Transaction Switches, and ES_ESM_* Variables Can Override Them