Operation [ Micro Focus COBOL System Reference, Volume 1 ] MPE/iX 5.0 Documentation
Micro Focus COBOL System Reference, Volume 1
Operation
The Generator is invoked using the -u or -x flag on the cob command line
(see the chapter COBOL System Interface (cob)). This section shows you
how to specify directives to the Generator, either when it is invoked or
using a variety of other methods. The generating process and segmented
program handling are also explained.
Directives
Directives are used to specify options that affect the way the Native
Code Generator behaves, what output it produces, what code is actually
generated and how the generated code behaves when run. All directives
have a default built into the Native Code Generator; however, you can
create your own defaults as described in the section Setting Directives.
The following sections describe how you can specify Generator directives.
Descriptions of the individual directives are contained in the appendix
Directives for Compiler.
Directives Syntax.
Generator directives are specified behind the -N cob flagin the following
format:
-N [no]keyword"parameter"
where:
no turns keyword off. no applies only to certain directives
where specified in their description in the appendix
Directives for Compiler.
keyword is one or more of the Generator directives described in the
appendix Directives for Compiler whose phase is indicated
as "generate". If you do specify more than one directive,
they must all be enclosed within quotation marks. This is
necessary to inform UNIX that all the directives within
them are grouped together. If you omit the quotation
marks, second and subsequent directives are ignored
although no warning to this effect is given.
"parameter" is a qualifier to keyword and applies only to certain
directives where specified in their description in the
appendix Directives for Compiler. It must appear in one of
the following forms:
"parameter"
or
=parameter
or
(parameter)
You must not include any spaces within a Generator
parameter. This is because UNIX treats the space character
as an option delimiter. Therefore, if you do include any
spaces within a Generator parameter, UNIX considers that
more than one has been specified. If parameter is
file-name, then it can be a fully specified file-name,
including path, unless otherwise stated.
We recommend that where possible you use the format of the parameter that
contains an equals sign before any parameter. cob maps the equals sign
(which has no special meaning to the Generator or to UNIX) to the format
which uses parentheses (as these do have a special meaning to the
Generator and UNIX). You are recommended to use this format because if
you use either of the other possible formats, you must escape the
quotation marks or parentheses with the backslash character (\) whenever
they might be misinterpreted by the UNIX shell. As the equals sign has
no special meaning, it does not need to be escaped.
Example.
The following examples illustrate two ways to specify the same Generator
parameters:
cob -x -N bound -N linkcheck pi.cbl
or
cob -xN "bound linkcheck" pi.cbl
Both of these examples cause the Native Code Generator to check for
run-time subscript limit violations and for the existence of each Linkage
Section item whenever it is referenced. The quotation marks in the
second example are necessary as they inform UNIX that all the material
within them is grouped behind the -N flag. If you omit the quotation
marks, second and subsequent directives are ignored, although no warning
to this effect is given.
Setting Directives.
Directives, which are specified prior to generating, can be entered in a
number of ways, and the order in which various directives are passed to
the Generator determines their precedence. See the chapter COBOL System
Interface (cob)for details. Regardless of where they are specified,
Generator directives always follow the -N cob flag.
Full details on the directives available are contained in the appendix
Directives for Compiler. Some of the directives are environment
dependent and may not be applicable to your particular environment (any
such restrictions are noted in the directive's description). The
Generator will accept them but will treat them as documentary only.
Examples.
The following examples illustrate the available methods of specifying
Generator directives.
* To specify the NOBOUND directive in the $COBDIR/cobopt file,
insert the line:
-N "nobound"
* To specify the NOCHECK LINKALIGN directives in the COBOPT
environment variable, enter:
COBOPT='-N "nocheck linkalign"'
* To specify the LINKALIGN directive on the cob command line for a
file called file1.cbl, enter:
cob -u -N linkalign file1.cbl
The Generating Process
If you do not specify the verbose option (-v cob flag), then the
generating process begins without displaying any messages, unless an
error is found.
If you do specify the verbose option on the cob command line, the Native
Code Generator accepts, rejects or ignores each option specified after
-v. Each option is acknowledged on a separate line. Those options
ignored are those which the Generator does not recognize or which are not
applicable to your environment. If an invalid parameter has been
specified for an option, the option is rejected and the generating
process stops.
After acknowledging all the options, the Native Code Generator opens its
files and starts to generate. At this point, it displays the message:
* Generating file-name
While generating your program, cob creates temporary files. These files
are placed in the directory indicated by the environment variable TMPDIR,
or in the directory /usr/tmp if TMPDIR does not exist (see the appendix
Micro Focus Environment Variables for details on TMPDIR). The size of
these files depends on the size of your program and the directives used.
You should ensure that there is enough free space in the temporary area
before starting the generation.
If the Generator cannot open your source file, it issues the message:
* File open failure: file-name
The generation is aborted and control is returned to UNIX. The most
likely causes of errors at this time are:
* you have not provided the correct file-name
* you have not provided the file extension (the extension must be
specified, even if it is .int). However, if you are processing
.cbl files to .gnt files in one step as follows:
cob -u file-name.cbl
then cob implicitly adds the extension .int.
* your file is not in the directory you have specified, it is not in
the current directory if you did not specify a path-name, or you
do not have the necessary access permission(s).
If no errors occur, then the system prompt reappears when the generating
process is complete. If you set the -v cob flag, then the Generator
first provides statistics on data and code size.
Generating Segmented Programs
When you generate native code for a segmented program, you specify on the
cob command line only the name of the root segment intermediate code
file. The Native Code Generator uses this name and establishes from
internal tables which overlay segments are present and generates all the
segments in a single run. The output files mirror the input files: a
root generated code file with extension .gnt and overlays with extensions
.gnn, where nn is in the range 50-99 corresponding to the COBOL segment
numbers. The exception to this is when a program is generated for static
linking. In this instance, all the overlays are contained in the root
file, which has the extension .o. On some environments, a single .gnt
file is produced for a segmented program. This has no effect on the
running of the program.
MPE/iX 5.0 Documentation