Chapter Contents

Previous

Next
Compiling C Programs

Compiling C Programs under CMS

This section explains how to use the LC370 EXEC, which invokes the SAS/C Compiler under CMS.


The LC370 EXEC

Invoke the compiler with the LC370 EXEC as follows:

LC370 filename [[.] filetype [[.] filemode]] [(options [)]]

or

LC370 ddn:ddname  [(options [)]]

where filename is the name of a C source file. The default filetype is C. If filemode is not specified, all accessed disks are searched. A DDN: type filename is illustrated in the following example:

LC370 DDN:SYSIN

where SYSIN is interpreted as a DDname defined by a FILEDEF. The following example is also acceptable:

LC370 DDN:ddname (member)

where member, which must be enclosed in parentheses, refers to a member of an OS/390 PDS. The member must immediately follow the DDname.

You can also specify Shared File System (SFS) files as input and output when you invoke the compiler. Specify SFS files when invoking the compiler as follows:

LC370 sf:filename  [filetype  [dirname]]

where dirname is the complete directory name or the NAMEDEF that has been logically assigned to it. If you omit filetype or dirname, the default filetype is C; the default directory name is a period (.), indicating the top directory.

The compiler writes its output files (LISTING, TEXT, and temporary) to different places, depending on the form of the input fileid. With the CMS fileid, the compiler writes output files to the input file minidisk, if that minidisk can be written to. Otherwise, the compiler writes output files to the A-disk. With the DDN: format, the compiler uses the DDname as the filename of the output files (with an appropriate filetype). The output files are written to the input file minidisk if possible. Otherwise, they are written to the A-disk. With the SFS fileid, the compiler writes the output files to the input file directory if that directory is writable. Otherwise, the compiler writes output files to the top directory.

You should issue a GLOBAL command for any MACLIB containing #include files before invoking LC370. The standard C macro library is in LC370 MACLIB. You also can set default options and default MACLIBs through a GLOBALV variable. See Using Environment Variables to Specify Defaults.

Sample LC370 EXEC command line with options

The following is another sample command line that invokes the compiler:

LC370 PROG (COMN PR TRA NOX

In this command, the fileid of the source file is PROG C. The compiler options used are comnest , print , trans , and noxref . These options are discussed in Compiler Options.

Note:    The LC370 EXEC does not accept the short form of the compiler options.  [cautionend]


Compiling C Programs from XEDIT

LCXED is an XEDIT macro that invokes the compiler from within XEDIT. When you submit the LCXED command, the file currently being edited is compiled. To use the LCXED macro, enter the following on the XEDIT command line:

LCXED [(options  [)]]

options can be any options acceptable to the LC370 EXEC.


Using Environment Variables to Specify Defaults

The compiler references certain environment variables

The compiler and COOL query environment variables in the GLOBALV group LC370 to determine if any default options, MACLIBs, or TXTLIBs have been specified. GLOBALV Group LC370 Variables lists the environment variables that can be defined in the LC370 group.

GLOBALV Group LC370 Variables
Variable Contents
_DB directory list to search for debugger table file
_HEADERS list of directories to search for included files
_INCLUDE list of files in CLINK INCLUDE statement
MACLIBS MACLIB(s) to be GLOBALed when the compiler is invoked
OPTIONS compiler options
TXTLIBS TXTLIB(s) to be GLOBALed when CLINK is invoked


Specifying Shared File System Directories

If you are using the CMS Shared File System (VM/SP Release 6 and later), you can use the _HEADERS and _INCLUDE environment variables to indicate a directory list for the compiler to search.

The syntax of specifying an environment variable is as follows:

GLOBALV SELECT LC370 SETL environment-variable directory-list

where directory-list is the list of directories that you want to be searched. You may specify either a directory name or a NAMEDEF when listing a directory that you want to be searched. The directories specified by the environment variable are searched in the order in which you listed them.

For example,

GLOBALV SELECT LC370 SET _INCLUDE .C.PROJ1 .C.PROJ2

instructs the compiler to search the .C.PROJ1 directory first and the .C.PROJ2 directory second as it looks for TEXT files.

You can also specify additional directory lists by defining other environment variables in the LC370 group. In this way, you can expand the list of directory names or NAMEDEFs that you want the compiler to search. An example of defining an environment variable for this purpose is as follows:

GLOBALV SELECT LC370 SETL MORE .SYSTEM.H .LOCAL.H

This example defines MORE as an environment variable that contains the .SYSTEM.H and .LOCAL.H directory names. Then, for example, you can specify the MORE environment variable within the _HEADERS variable by preceding it with an ampersand (&), as in the following:

GLOBALV SELECT LC370 SETL _HEADERS .PROJECT.H .COMMON.H &MORE

In this example, the compiler searches the .PROJECT.H and .COMMON.H directories and the .SYSTEM.H and .LOCAL.H directories listed in the MORE environment variable.

You can mix directory names, NAMEDEFs, and environment variables within an environment variable. Secondary environment variables, such as MORE in the preceding example, can specify tertiary environment variable names, and so on, to any depth. An example of specifying a tertiary environment variable follows:

GLOBALV SELECT LC370 SETL MORE .SYSTEM.H .LOCAL.H &MORE2

In this example, the environment variable MORE lists the .SYSTEM.H and .LOCAL.H directories and the directories listed in the &MORE2 environment variable. Note again that the tertiary environment variable defined in MORE must be preceded by an ampersand (&). The ability to list environment variables in successive levels circumvents the environment variable limit of 255 characters.

If the compiler does not find the included file in any directory that an environment variable specifies, it behaves as though you have not specified an environment variable at all. The compiler searches the top directory first. If it does not find the included file in the top directory, the compiler searches the accessed minidisks.


Other Environment Variables

You can specify a list of default compiler options with the OPTIONS environment variable. If compiler options are specified both by using the OPTIONS variable and on the command line, the command-line options override those specified by the OPTIONS variable. You can specify a default list of macros to be searched for header files with the MACLIBS environment variable. You can specify a default list of TXTLIBs to be used for autocall in COOL with the TXTLIBS environment variable. The EXECs also retain the current GLOBALed MACLIBs and TXTLIBs before issuing a new GLOBAL command, and they restore the status after the compiler or COOL has terminated. All of the EXECs accept the noglobal option. If this option is used, no MACLIBs or TXTLIBs are GLOBALed by the EXEC. For example, the following CMS GLOBALV command creates a list of default options to be used when the compiler is invoked:

GLOBALV SELECT LC370 SETL OPTIONS COMNEST RENT HLIST

The following GLOBALV command specifies that the LC370 MACLIB is to be GLOBALed when the compiler is invoked:

GLOBALV SELECT LC370 SETP MACLIBS LC370


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.