Using the SAS/C C++ Development System under TSO, CMS, OS/390 Batch, and UNIX System Services |
Before
running the translator, compiler, COOL, or any C++ program, ensure that the
transient library is available on an accessed minidisk or that it is installed
in a segment available to your virtual machine. Consult your SAS Installation
Representative to determine if this has been done for you.
The LCXX
EXEC invokes the translator and compiler. Optionally, you can also invoke
the OMD370 object module disassembler utility. The LCXX EXEC has the following
format:
LCXX fileid <(options<)>>
|
where
fileid is the fileid of the file
to be translated and compiled. The fileid can name a file on a CMS minidisk,
a file in the XEDIT ring, or a file in a Shared File System (SFS) directory.
The format of the fileid is described in Specifying a fileid. The options are any translator
options, compiler options, or, if the OMD option is used to invoke the OMD370
utility, OMD370 options. See Option Summary for the options that are available for use with the translator.
By
default, the translator writes its output (C code)
to a temporary file and runs the compiler if no errors were found. The name
of the output file has the same filename as the input file and a filetype
of TROUT. If the input file is on an accessed minidisk or directory accessed
as a minidisk, the temporary output file is written on that minidisk. If the
minidisk is not write-accessed, the output file is written to the minidisk
accessed as filemode A. If the input file is in an SFS directory that is not
accessed as a minidisk, the output file is written to that directory. If the
directory is not writable, the output file is written to your top directory.
If the input file is in the XEDIT ring, the output file is written to the
minidisk accessed as filemode A.
Note:
If you have an existing file with the same name
as the C output file, it is overwritten and then erased. Therefore, you may
want to use the
savec
option to specify a different name for the
output file, as discussed in the following section.
You can use three options to save the intermediate code produced
by the translator:
pponly
,
tronly
, and
savec
. Here
is a brief description of each of these options:
For detailed information on these three options, refer
to Option Descriptions.
Note:
Because both
tronly
and
savec
save the intermediate C code
file, you should use only one of them. For example, if you use
tronly
, you
do not need to also specify
savec
, unless you want to rename the intermediate
C code file.
The following sections illustrate
specifying fileids (for both
input and output files). The examples are divided according to your file environment,
such as files on accessed minidisk or directory, files on the XEDIT ring,
and files in a Shared File System (SFS) directory.
To
specify a file on an accessed minidisk or directory, use
filename <filetype <filemode>>
Optionally, you can separate the filename, filetype,
and filemode by periods instead of blanks. If the file is on an accessed minidisk
or directory, you can optionally prefix the fileid with
cms:
. If the filetype is omitted, the default
filetype for the input file is CXX. If the filemode is omitted, the translator
searches all accessed minidisks and directories. Here are some examples:
-
LCXX MYPROG
-
The input file is MYPROG CXX *. The output
file is temporary and is named MYPROG TROUT. The output file is written to
either the minidisk where the input file was found or to the A disk if the
input minidisk is not writable.
-
LCXX MYPROG.CPP
-
The input file is MYPROG CPP *. The output
file is temporary and is named MYPROG TROUT.
-
LCXX MYPROG (SAVEC MYPROG CPPOUT B2
-
The input file is MYPROG CXX *. The
savec
option stores the output
file as MYPROG CPPOUT B2.
-
LCXX CMS:MYPROG.CPP.J (NOWARN SAVEC CMS:MYPROG.CPPOUT.B2
-
The input file is MYPROG CPP J. The
nowarn
option suppresses translator
warning messages. The
savec
option stores the output file as MYPROG CPPOUT B2. Note that the
savec
option must be the last option specified.
If you run the LCXX EXEC from the XEDIT command line and the
input file is in the XEDIT ring, the translator automatically reads the input
file from XEDIT. However, the translator does not write its output to an XEDIT
file.
To specify a file in an SFS directory, use the following format:
sf: filename <filetype <directory-name |
namedef>>
|
The
sf:
prefix is required. If the filetype is omitted, the default filetype
is CXX. If you do not specify either a directory-name or a NAMEDEF, the default
is your top directory. Here are some examples:
-
LCXX SF:MYPROG
-
MYPROG CXX
-
is the input file.
-
MYPROG TROUT
-
is the temporary output file.
-
-
LCXX SF:MYPROG CPP
-
MYPROG CPP.
-
-
MYPROG TROUT
-
is the temporary output file.
-
-
LCXX SF:MYPROG (SAVEC MYPROG CPPOUT
-
-
MYPROG CXX.
-
is the input file.
-
MYPROG CPPOUT.
-
is the permanent output file, created by
the
savec
option. Note
that the output file prefix defaults to the input file prefix.
-
LCXX SF:MYPROG CXX
CXXPROG
-
MYPROG CXX CXXPROG
-
is the input file, where CXXPROG is a NAMEDEF
defined in a NAMEDEF command.
-
MYPROG TROUT.
-
is the temporary output file.
-
-
LCXX SF:MYPROG CXX .CXX.PROJ (SAVEC CMS:MYPROG TROUT
B2
-
MYPROG CXX .CXX.PROJ
-
is the input file.
-
MYPROG TROUT B2
-
is the permanent output file, created by
the
savec
option. The
cms:
prefix is used to override
the default prefix of
sf:
.
-
The
translator searches for header files in one of two locations, depending on
how the filename is specified in the
#include
statement. When the filename
is surrounded by angle brackets in the
#include
statement, the translator
assumes that the header file is a member of a macro library that has been
designated GLOBAL. The syntax for this form of the
#include
statement is
#include <member.ext>
The .ext part can be omitted.
For example:
#include <new.h>
In this case, the translator includes the first member
named NEW that it finds in the GLOBAL macro libraries.
When the filename is surrounded by double quotes in
the
#include
statement, the translator searches for the specified file.
The syntax for this form of the
#include
statement is
#include "fileid"
fileid can be any CMS fileid in
the
cms:
,
xed:
, or
sf:
formats. For example, suppose you had the following
#include
statement in your program:
#include "project.h"
In this case, the translator attempts to include the
file named PROJECT H *. If this file cannot be found, the translator searches
the macro libraries that have been designated GLOBAL. The translator uses
that part of the fileid preceding any blank or period as the member name.
Refer to the SAS/C Library Reference,
Third Edition, Volume 1 for more information about CMS filename formats.
If you are using the translator in a version of CMS
that supports the Shared File System, the translator automatically searches
your top directory for header files before searching any accessed minidisks.
You can specify additional directories to be searched by using the _HEADERS
environment variable. Refer to the SAS/C Compiler
and Library User's Guide for more information about using environment
variables.
Before invoking the LCXX EXEC, be sure that the C++
standard header files and C standard header files are available. The C++ standard
header files are in a macro library named LCXX370 MACLIB. The C standard header
files are in a macro library named LC370 MACLIB. To make these header files
available to the translator, issue the following command before calling the
translator:
GLOBAL MACLIB LCXX370 LC370
If your program requires header files in another macro
library, add the filename of the macro library to the GLOBAL MACLIB command.
The LCXX EXEC automatically issues
a GLOBAL MACLIB command for you if you set the CXXMACLIBS environment variable
to the names of the macro libraries you want to be made available. In addition,
if you set the CXXOPTIONS environment variable to a list of translator options,
LCXX automatically passes those options to the translator in addition to the
options you specify on the command line. Set these variables using the GLOBALV
command. Both variables should be in the LC370 group.
The GLOBALV command (see CXXMACLIBS GLOBALV Command) sets the
CXXMACLIBS variable so that the
LCXX EXEC automatically issues a GLOBAL MACLIB command for the C++ standard
header files and the C standard header files.
CXXMACLIBS GLOBALV Command
GLOBALV SELECT LC370 SETLP CXXMACLIBS LCXX370 LC370
You can suppress the use of environment variables for
a single compilation by specifying the NOGLOBAL option on the LCXX command
line.
The following example shows how to set the CXXOPTIONS
variable to cause LCXX to automatically pass the
overload
option to the translator:
GLOBALV SELECT LC370 SETP CXXOPTIONS OVERLOAD
Options specified on the command line override options
specified via the CXXOPTIONS variable.
All
C++ programs must be preprocessed by the COOL object code preprocessor because
COOL automatically creates object code used during the initialization and
termination of static objects. In addition, COOL supports linking object files
that contain mixed case external names longer than eight characters, such
as those created by the compiler for source code generated by the translator.
Such external names cannot be handled by the linkage editor unless the object
code has been preprocessed by COOL.
The
COOL EXEC calls COOL to preprocess your object code, and it optionally invokes
the CMS GENMOD command. The format of the COOL EXEC is
COOL <filename1 <filename2 . . .>> (CXX
<options<)>>
|
Filename1, filename2, and so on are the
filenames of primary input files or AR370 archives. For each filename in the
list, COOL first checks for an AR370 archive with this filename; if one is
not found, it looks for a TEXT file. For instance, if the filename FINANCE
is specified, COOL first looks for FINANCE A, an AR370 archive on an accessed
minidisk or in an SFS directory accessed as a minidisk. If FINANCE A is not
found, COOL looks for FINANCE TEXT. Any TEXT files specified on the command
line may contain object code, COOL control statements, or both. Any AR370
archives specified on the command line are used to resolve unresolved references
during the processing of the other input files.
For example, the following command line causes COOL
to use MYPROG TEXT as its only input file, provided that MYPROG A is not found:
COOL MYPROG (CXX
If you do not specify any filenames, COOL prompts you
for filenames. Enter as many filenames as necessary in response to the COOL:
prompt. Enter a null string (that is, press the ENTER key) to cause COOL to
begin processing the input files.
The CXX option is the only required option. This option
causes the standard C++ object library to be added to COOL's autocall list.
Refer to COOL Options for more information about COOL options. Before calling COOL, you must issue
a GLOBAL TXTLIB command to make the standard C object libraries available
for autocall resolution. The standard C object libraries are LC370BAS TXTLIB
and LC370STD TXTLIB.(footnote 1) The following GLOBAL TXTLIB command makes these libraries available
for COOL:
GLOBAL TXTLIB LC370BAS LC370STD
The COOL EXEC automatically issues a GLOBAL TXTLIB command
for you if you specify the names of the object libraries in the TXTLIBS environment
variable.
The COOL input files can contain control statements
instead of, or in addition to, object code. For more information about COOL
control statements, refer to COOL Control Statements.
COOL writes the preprocessed object code to a file named
COOL370 TEXT A1. This file can be used as input to the LOAD command or the
LKED command.
The COOL listing file is written to the terminal by
default. You can redirect it to a disk file. Enter the redirection argument
in the filename part of the command line, not the options part. For example,
the following command causes COOL to write its listing file to MYPROG COOLMAP
A1:
COOL MYPROG >MYPROG.COOLMAP.A1 (CXX
There are many special considerations for linking C++
programs under CMS that parallel the considerations for linking C programs.
Refer to the SAS/C Compiler and Library User's Guide for a complete
discussion of these considerations.
The COOL EXEC
accepts the GENMOD option, which specifies that the EXEC should load the COOL370
TEXT file and issue the GENMOD command. You can specify the name of the MODULE
file following the GENMOD option. If you do not specify a name, the COOL EXEC
uses the first input filename on the command line as the name of the MODULE.
For example, the following command creates MYPROG MODULE:
COOL MYPROG LIBFNC (CXX GENMOD
The following command creates APPL1 MODULE:
COOL MAIN1 SUB1 SUB2 (CXX GENMOD APPL1
You can also cause COOL to invoke the START command
or the LKED command. Refer to the SAS/C Compiler and Library User's
Guide for more information.
C++
programs can be run just like any other program under CMS. The most frequently
used method for running a program is to create a MODULE file (as shown previously)
and then call the module as a CMS command. For example, the following command
calls MYPROG MODULE, passing the program option
-z
, the run-time option
=48k
, and redirecting
stdin
to INPUT FILE *:
MYPROG -z =48k <INPUT.FILE
You can also load a TEXT file and use the START command
to run it. For example, suppose you have created MYFILE TEXT by using COOL
to preprocess MYPROG TEXT. The following commands can be used to load and
run it, passing the same options as in the previous example:
LOAD MYFILE
START * -z =48k <INPUT.FILE
Programs that can be called from the CMS EXEC processor
should be prepared to accept tokenized parameters. This form of parameter
is at most eight characters long and is translated to uppercase by CMS. Refer
to the SAS/C Compiler and Library User's Guide for more information.
If you want to run your program with the SAS/C Debugger, use the '=D' option
when you call your program, as in the following example:
MYPROG =D
For more information on debugging C++ programs, refer
to Debugging C++ Programs Using the SAS/C Debugger.
FOOTNOTE 1:
The standard
C++ object library is named LIBCXX A. Other run-time libraries include LC370GOS
TXTLIB for use with the Generalized Operating System, LC370SPE TXTLIB for
use with the Systems Programming Environment, and LC370CIC TXTLIB for use
with the SAS/C CICS Command Language Translator.
Copyright © 2001
by SAS Institute Inc., Cary, NC, USA. All rights reserved.