[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
User Manual


Previous Contents Index

For more information about using Oracle CDD/Repository and creating and maintaining text libraries, refer to the HP COBOL Reference Manual and Using Oracle CDD/Repository on OpenVMS Systems.

1.2.2 Compiling an HP COBOL Program on OpenVMS

To compile your program, use the COBOL command. The HP COBOL compiler performs these primary functions:

  • Detects errors in your program.
  • Displays each compiler message on your terminal screen.
  • Generates machine language instructions from valid source statements.
  • Groups these language instructions into an object module for the linker.
  • Creates an analysis file if you request it with the /ANALYSIS_DATA qualifier. SCA uses this file to display information about program symbols and source files.

The compiler outputs an object module that provides the following information:

  • The name of the entry point. It takes this name from the program name in the first PROGRAM-ID paragraph in the program.
  • A list of variables that are declared in the module. The linker uses this information when it binds two or more modules together and must resolve references to the same names in the modules.
  • Traceback information. This information is used by the system default condition handler when an error occurs that is not handled by the program. The traceback information permits the default handler to display a list of the active blocks in the order of activation; this is an aid in program debugging.
  • A symbol table and a source line correlation table, only if you request them with the /DEBUG qualifier. A symbol table is a list of the names of all external and internal variables within a module, with definitions of their locations. The source line correlation table associates lines in your source file with lines in your program. These tables are of primary help when you use the OpenVMS Debugger.

To invoke the HP COBOL compiler, use the COBOL command (explained in Section 1.2.2.1). You can specify qualifiers with the COBOL command. The following sections discuss the COBOL command and its qualifiers.

1.2.2.1 Format of the COBOL Command on OpenVMS

The COBOL command has the following format:


COBOL [/qualifier] ... {file-spec [/qualifier] ...} ...

/qualifier

Specifies an action to be performed by the compiler on all files or specific files listed. When a qualifier appears directly after the COBOL command, it affects all the files listed. By contrast, when a qualifier appears after a file specification, it affects only the file that immediately precedes it. However, when files are concatenated, these rules do not apply.

file-spec

Specifies an input source file that contains the program or module to be compiled. You are not required to specify a file type; the HP COBOL compiler assumes the default file type COB. If you do not provide a file specification with the COBOL command, the system prompts you for one.

1.2.2.2 Compiling Multiple Files

You can include more than one file specification on the same command line by separating the file specifications with either a comma (,) or a plus sign (+). If you separate the file specifications with commas, you can control which source files are affected by each qualifier. In the following example, the HP COBOL compiler creates an object file for each source file but creates only a listing file for the source files entitled PROG_1 and PROG_3:


$ COBOL/LIST PROG_1, PROG_2/NOLIST, PROG_3

If you separate file specifications with plus signs, the HP COBOL compiler concatenates each of the specified source files and creates one object file and one listing file. In the following example, only one object file, PROG_1.OBJ, and one listing file, PROG_1.LIS, are created. Both of these files are named after the first source file in the list, but contain all three modules.


$ COBOL PROG_1 + PROG_2/LIST + PROG_3

Any qualifiers specified for a single file within a list of files separated with plus signs affect all files in the list.

1.2.2.3 Debugging a Program

To effectively debug an HP COBOL program, you must first make symbol and traceback information available by adding the DEBUG option to the compile command line. You specify the /DEBUG option as follows:


$ COBOL/DEBUG myprog
$ LINK/DEBUG myprog
$ RUN/DEBUG myprog

This enables you to examine and modify variables, monitor flow of control, and perform various other debugging techniques. See Section C.3 or type HELP COBOL/DEBUG or HELP DEBUG for additional information.

On Alpha and I64, when you compile a program with /DEBUG, you should also specify /NOOPTIMIZE to expedite your debugging session. (The default is /OPTIMIZE.) Optimization often changes the order of execution of the object code generated for statements in a program, and it might keep values in registers and deallocate user variables. These effects can be confusing when you use the debugger. (A diagnostic message warns you if you compile an HP COBOL program with /DEBUG without specifying anything about optimization on the command line.)

Pay attention to compiler messages. Informational and warning messages (as well as error-level messages) do not prevent the production of an object file, which you can link and execute. However, the messages sometimes point out otherwise undetected logic errors, and the structure of the program might not be what you intended.

1.2.2.4 Separately Compiled Programs (Alpha, I64)

If a compilation unit consists of multiple separately compiled programs (SCPs), by default the HP COBOL compiler produces a single object file that consists of a single module with multiple embedded procedures. This object file can be inserted into an object library. If your build procedure requires that the linker extract any part of the module, the linker must extract the entire object.

If you use /SEPARATE_COMPILATION on the compile command line, HP COBOL will compile multiple SCPs into a single object file that consists of a concatenation of modules, each containing a single procedure. This object may then be inserted into an object library from which the linker can extract just the procedures that are specifically needed. <>

1.2.2.5 COBOL Qualifiers

COBOL options (also known as qualifiers or flags) control the way in which the compiler processes a file. You can process your file with the COBOL command alone or you can select options that offer you alternatives for developing, debugging, and documenting programs.

If you compile parts of your program (compilation units) using multiple COBOL commands, options that affect the execution of the program should be used consistently for all compilations, especially if data will be shared or passed between procedures.

Table 1-4 lists the COBOL command options and their defaults. For more information about COBOL options, invoke online help for COBOL at the system prompt.

Note

Brackets ([]) indicate that the enclosed item is optional. If you specify more than one option for a single qualifier, you must separate each option with a comma and enclose the list of options in parentheses.

Table 1-4 COBOL Command Qualifiers
   


Previous Next Contents Index