HP OpenVMS Systems Documentation
To specify a file name (other than a.out ) for the executable image file, use the -o output flag, where output specifies the file name. You can also use the mv command to rename the file. The following command requests a file name of prog1.out for the source file test1.cob :
% cobol -o prog1.out test1.cob
Besides specifying the name of the executable image file, you can use
to rename the object file if you specified the
flag. If you specify the
flag and omit the
output flag, the name of the first specified file is used with
suffix substituted for the source file suffix.
220.127.116.11 Temporary Files
Temporary files created by the compiler or a preprocessor reside in the /tmp directory and are deleted (unless the -K flag is specified). You can set the environment variable TMPDIR to specify a directory to contain temporary files if /tmp is not acceptable.
To view the file name and directory where each temporary file is
created, use the
flag. To create object files in your current working directory, use the
flag. Any object files (
files) that you specify on the
command line are retained.
18.104.22.168 Examples of the COBOL Command
The following examples show the use of the cobol command. Each command is followed by a description of the output files that it produces.
% cobol -V aaa.cob bbb.cob ccc.cob
The HP COBOL source files aaa.cob , bbb.cob , and ccc.cob are compiled into temporary object files. The temporary object files are passed to the ld linker. The ld linker produces the executable file a.out . The -V flag causes the compiler to create the listing files aaa.lis , bbb.lis , and ccc.lis .
% cobol -V *.cob
When the compilation completes, the cobol driver returns one of the following status values:
2---SUBPROCESS_FAILURE ( cobol or cc )
You can compile and link multilanguage programs using a single cobol command.
The cobol command recognizes C or Assembler program files by their file suffix characters and passes them to the cc compiler for compilation. Before compilation, cc applies the cpp preprocessor to files that it recognizes, such as any file with a .c suffix.
Certain flags passed to
are passed to the
22.214.171.124 Interpreting Messages from the Compiler
The HP COBOL compiler identifies syntax errors and violations of language rules in the program. If the compiler finds any errors, it writes messages to the stderr output file and any listing file. If you enter the cobol command interactively, the messages are displayed on your terminal.
Compiler messages have the following format:
cobol: severity: filename, line n, message-text [text-in-error] --------^
The pointer ( --^ ) indicates the exact place on the source line where the error was found. For example, the following error message shows the format and message text in a listing file when an END DO statement was omitted:
cobol: Severe: disp.cob, line 7: Missing period is assumed 05 VAR-1 PIC X. --------^
The severity level is one of the following:
|Severe||The compiler does not produce an object module. You must correct the error before you can compile the program to produce an object module.|
|Error||The compiler makes an assumption about what you intended and continues. However, the compiler's assumption may not relate to your intention. Correct the error.|
|Warning||The compiler attempts to correct the error in the statement, but you should verify that the compiler's action is acceptable. Otherwise, your program may produce unexpected results.|
|Informational||This message usually appears with other messages to inform you of specific actions taken by the compiler. No action is necessary on your part.|
Any messages issued during the compilation are inserted in the listing file. A listing file is useful for debugging the source code. Use the -V or -list flag to produce a listing; you may also use -cross_reference , -copy_list , -flagger , -machine_code , -map , and/or -warn , all of which affect the contents of the listing file.
Diagnostic messages provide information for you to determine the cause
of an error and correct it. If the compiler creates a listing file, it
writes the messages to the listing file.
1.1.3 Linking an HP COBOL Program on Tru64 UNIX
Once your program has compiled successfully, the system passes the resulting object file (which has the suffix .o by default) to the linker to create an executable image file. By default, the executable image file has the name a.out. (To change this default, specify -o filename on the cobol command line.) This file can be run on the Tru64 UNIX system.