Skip to content

The cobc COBOL Compiler

cobc is the COBOL-IT Open Source COBOL compiler.

cobc translates COBOL programs to C code and compiles it using the C platform compiler. However, this C code is just a compilation artifact that provides portability and performance. It is not meant to be maintained, or even read. Except for the cases where the developer will be interfacing COBOL-IT with other libraries or dealing with other similarly low-level task, there is no need for the developer to even be aware of this intermediate C code, or any other C-related topic.

For a more detailed presentation of the steps cobc goes through in creating an executable object, see What cobc does.

This chapter provides an overview of supported compiler flags, and environment variables, and includes a section highlighting some important usage cases.

Usage: >cobc [options] file...

The COBOL-IT Compiler supports over 100 compiler flags. For a full list, execute the command:

cobc -help

Informational Flags

Informational compiler flags do not produce any objects, and are used to display information about the COBOL-IT compiler.

  • check-codepage <codepage-id>

    The -check-codepage <name> compiler flag is an informational compiler flag that you can use to check if a given codepage is recognized by the ICU library.

    Example:

    To check for support of codepage 500, ( which is supported ): C:\COBOL\COBOLIT>cobc -check-codepage 500

    500 is found as ibm-500_P100-1995

    To check for support of codepage 13488 ( which is not supported): C:\COBOL\COBOLIT>cobc -check-codepage 13488

    Internal Error: can't open converteur 13488 : U_FILE_ACCESS_ERROR

  • help

    Display this message

  • list-codepage

    The -list-codepage compiler flag is an informational compiler flag that lists all supported codepages in the following format:

    Codepage: [ list of synonyms for codepage ]

    As an example: UTF-8 : UTF-8 ibm-1208 ibm-1209 ibm-5304 ibm-5305 ibm-13496 ibm-13497 ibm-17592 ibm- 17593 windows-65001 cp1208 x-UTF_8J unicode-1-1-utf-8 unicode-2-0-utf-8

  • list-intrinsics

    Display intrinsic functions

  • list-mnemonics

    Display mnemonic names

  • list-reserved

    Display all reserved words

  • version, -V

    Display compiler version

Standard Flags

Standard compiler flags are applied to COBOL-IT's basic build process, which consists of separate preprocess, translate, compile, assemble, and link steps, and are used to direct the compiler in basic functions such as locating copy files, placing object files, creating listing files, adding error-checks, and adding information required for running with the COBOL-IT debugger.

See Standard Flags for a complete description of these flags.

Compiler -f Flags

-f compiler flags describe a context in which the compiler should generate code in a prescribed way. As such, they are used to enable optimizations, to enforce behaviors compliant with other COBOLs, to create thread-safe code, and to enable the use of utilities such as the debugger, tracing, memory dumps, and profiling.

See Compiler -f Flags

Compiler -w Flags

-w compiler flags are warning flags.

See Compiler -w Flags

Back to top