Chapter Contents

Previous

Next
Compiling C Programs

Compiling C Programs under OS/390 Batch

This section discusses the cataloged procedures and compiler JCL requirements necessary for executing the compiler under OS/390 batch.


The LC370C Cataloged Procedure

The procedure LC370C runs the compiler and, optionally, runs the object module disassembler. The object module disassembler can be used as an aid in debugging at the machine-code level. If you want to execute the OMD by itself, refer to The LC370D cataloged procedure. See Sample JCL for Compiling with Procedure LC370C for typical JCL to run LC370C.


Sample JCL for Compiling with Procedure LC370C
//COMPILE JOB job card information //*------------------------------------------------------------- //* COMPILE A C PROGRAM //* REPLACE GENERIC NAMES AS APPROPRIATE //*------------------------------------------------------------- //STEP1 EXEC LC370C,PARM.C='options' //C.SYSLIN DD DISP=OLD,DSN=your.object.library(member) //C.SYSIN DD DISP=SHR,DSN=your.source.library(member) //C.libddn DD DISP=SHR,DSN=your.macro.library //

When you use LC370C, you only need to provide DD cards for SYSIN (your source data set) and SYSLIN (your object data set). Use the DD statement C.libddn to identify the macro library for any #include 'member.libddn' statements in your source code. Refer to Include-File Processing for detailed information on #include files.

The LC370C procedure contains the JCL shown in Expanded JCL for LC370C. This JCL is correct as of the publication of this guide. However, it may be subject to change.


Expanded JCL for LC370C
//LC370C PROC //**************************************************************** //* PRODUCT: SAS/C *** //* PROCEDURE: COMPILATION *** //* DOCUMENTATION: SAS/C COMPILER AND LIBRARY USER'S GUIDE *** //* FROM: SAS INSTITUTE INC., SAS CAMPUS DRIVE, CARY, NC *** //**************************************************************** //* //C EXEC PGM=LC370B //STEPLIB DD DSN=SASC.LOAD, // DISP=SHR COMPILER LIBRARY // DD DSN=SASC.LINKLIB // DISP=SHR RUNTIME LIBRARY //SYSTERM DD SYSOUT=A //SYSPRINT DD SYSOUT=A //SYSUT1 DD UNIT=SYSDA,SPACE=(TRK,(10,10)) //SYSUT2 DD UNIT=SYSDA,SPACE=(TRK,(10,10)) //SYSUT3 DD UNIT=SYSDA,SPACE=(TRK,(10,10)) //SYSLIN DD DSN=&&OBJECT,SPACE=(3200,(10,10)),DISP=(MOD,PASS), // UNIT=SYSDA //SYSLIB DD DSN=&MACLIB, // DISP=SHR STANDARD MACRO LIBRARY //SYSDBLIB DD DSN=&&DBGLIB,SPACE=(4080,(20,20,1)),DISP=(,PASS), // UNIT=SYSDA,DCB=(RECFM=U,BLKSIZE=4080) //SYSTMP01 DD UNIT=SYSDA,SPACE=(TRK,25) VS1 ONLY //SYSTMP02 DD UNIT=SYSDA,SPACE=(TRK,25) VS1 ONLY /*

Note the following about this JCL:


Sample use of LC370C with options

The following is a sample EXEC statement that invokes LC370C and passes compiler options via the PARM parameter:

// EXEC LC370C,PARM.C='COMNEST,NOTRANS,PRINT,NOXREF'


Compiler Options (Short Forms)

The SAS/C compile process is divided into several phases. Calls to each phase are normally controlled by a front-end command processor. These front-end processors accept what are referred to as long-form options. When invoking the various phases, the front-end processors convert the options applicable to each phase to a form referred to as short-form options. Each phase only accepts the short-form versions of its options.

If you write your own JCL to invoke the compiler phases, you must pass short-form options in place of the options documented elsewhere in this book. You should not pass short-form options to any of the standard front ends, as the results are unpredictable.

The option string is case insensitive and has the following format:

c: compiler-options  p: listing-options  x: xref-options
    o: optimizer-options

where compiler-options, listing-options, xref-options, and optimizer-options are any or none of the options listed in Compiler Option Equivalents. Options must be separated by blanks. You can suppress the production of a source listing by using !p: instead of p: . Similarly, you can suppress the cross-reference by using !x: instead of x: . (Note that the not sign (¬) can be used instead of the exclamation point ( ! ). This has the advantage that ¬ prints in your JCL listing even on a printer without the full C character set.) To suppress global optimization, you omit the LCGO step and specify the quad file produced by phase 1 as input to LC2370. Following are two examples of an options string.

The first example is as follows:

// EXEC PGM=LC1370,PARM='p: !t -i -h !x:'

This is equivalent to the following LC370C specification to the LC370B front end:

// EXEC LC370C,PARM.C='NOTRANS,ILIST,HLIST,NOXREF'

The second example uses uppercase characters and the ¬ instead of !" :

// EXEC PGM=LC1370,PARM='C: -RX -SXYZ ¬P: O: -L'

This parameter string is equivalent to the following:

// EXEC LC370C,PARM.C='RENTEXT,SNAME(XYZ),NOPRINT,OPTIMIZE,LOOP'

Options for the global optimization phase should be supplied both to phase 1 and to the global optimizer. When passing them to phase 1, they should be preceded with o: . For example, suppose the following EXEC statement is issued:

// EXEC PGM=LC1370,PARM='o: -il !l'

This is equivalent to the following LC370C specification to the LC370B front end:

// EXEC LC370C,PARM.C='OPTIMIZE,INLOCAL,NOLOOP'

However, omit the o: when you pass the options to the global optimization phase. Remember that phase 1 just prints the global optimization options on the listing. You must pass them as parms to the global optimization phase for them to take effect.

Compiler Option Equivalents lists the short-form equivalents for the compiler, listing, cross-reference, and optimizer options. In general, each option is one or two characters. Precede the short form of a compiler option with a hyphen (-) for the positive form and with an exclamation point (!) or not sign (¬) for the negative form. (The negative form is the equivalent of a long form with the NO prefix.) For simplicity, only the positive form of each option is shown, even if the default value is negative. For example, -r is given for rent , even though the default value is norent . See Compiler Options for a complete explanation of each option.

These compiler long form and short form options are functionally equivalent, but they are not implemented identically. Compiler long form options can be used only when invoking the compiler with the LC370B driver, which is called by the standard SAS/C cataloged procedures. LC370B converts the long form options to short form options for subsequent processing by LC1370.

Compiler short form options should be used only when directly calling LC1370. Passing short form options in the PARM string when using a SAS/C cataloged procedure produces unpredictable results.

Compiler Option Equivalents
Long Form Short Form Long Form Short Form
Compiler
armode -ea asciiout -ao
at -ca bitfield(n) -bfn
bytealign -b comnest -cc
cxx -cxx dbgmacro -xp
dbhook -xlo debug -d
define(sym=val) -ddsym=val dollars -cd
enforce(n) -y¬n extname -n!
files(xxx) -fxxx hmulti -ih
igline -igl indep -i
ipath -i$ japan -j
knobinder none lineno -l
mention(n) -y+n pflocal -4
posix -lp ppix -co
pponly -p redef -cr
refdef -rd rent -r
rentext -rx reqproto - cf
sname(name) -sname stmap -s
strict -ll stringdup -cs
suppress(n) -yn term -t
trigraphs -cg undef -u
usearch -hu vstring -v
zapmin(n) -zmn zapspace(n) -zn
Listing
enxref -n exclude -e
hlist -h ilist -i
maclist / mlist -m options -o
overstrike -to pagesize(nn) -pnn
print :p source -s
trans -t upper -u
warn -w

Cross-Reference
hxref -h ixref -i
xref x:

Optimizer
alias -a complexity(n) -icn
depth(n) -idn freg(n) -rfn
greg(n) -rgn inline -in
inlocal -il loop -l
optimize o: rdepth(n) -irn


Compiler JCL Requirements

This section discusses the data definition statements needed to run the compiler under OS/390 if you are writing your own JCL. The short forms of the compiler options, used when invoking the compiler without using the LC370B front end, are given. The compiler runs in three phases. The first phase, LC1370, reads the source file and produces an intermediate file (called the quad file) and the optional source listing. The second phase, LCGO, reads the quad file and produces a new, optimized quad file. LCGO is the global optimization phase referred to elsewhere in this manual. This phase is optional (unless you are compiling with debug , in which case it cannot be used because debug and optimize are not compatible). If LCGO is not used, the quad file produced by LC1370 can be input directly to the third phase. The third phase, LC2370, reads the quad file and generates the object module.

All compiler options are processed by LC1370, with the exception of the global optimization options. These are processed by LCGO but are also accepted by LC1370 so that they can be printed on the listing. If you are writing your own JCL, be sure that you supply the same global optimization options to both LC1370 and LCGO to ensure that the options used by LCGO are the same as the options printed by LC1370.

In summary, you can choose to run the compiler with or without the global optimization phase. If you run the compiler without the global optimization phase, you can also use the debug option. Sample JCL for each of these approaches is provided following Data Definition Statements for Program Compilation. You need the data definition (DD) statements shown in Data Definition Statements for Program Compilation to invoke the compiler.

Note:    All of the DDnames shown in Data Definition Statements for Program Compilation can be specified as either an OS/390 data set or an HFS filename, with the exceptions of SYSLIB, H, SYSTERM, and SYSDBLIB. SYSLIB and H can be specified as either an OS/390 PDS or an HFS directory, whereas, SYSTERM and SYSDBLIB must not be HFS files or directories.  [cautionend]

Data Definition Statements for Program Compilation
DDname Purpose
LC1370
SYSLIB #include files (implementation-provided)
H (or other) #include files (user-provided)
SYSPRINT compiler listing and error messages
SYSTERM run-time error messages
SYSUT1 intermediate file (passed to LCGO or LC2370)
SYSUT2 debugger information file (only needed if debug in effect)
SYSIN input source (sequential or PDS member)
LCGO
SYSPRINT global optimization messages
SYSTERM run-time error messages
SYSUT1 intermediate file from phase 1
SYSUT3 optimized intermediate file (passed to LC2370)
LC2370
SYSPRINT compiler messages
SYSTERM run-time error messages
SYSUT1 intermediate file from LCGO or phase 1
SYSUT2 debugger information file from phase 1 (only if debug is in effect)
SYSDBLIB output debugger file (must be a partitioned data set)
SYSLIN output object module (sequential or PDS member)

All files other than SYSTERM can be USS HFS files.

Running the compiler with the global optimization phase

The sample JCL in Sample JCL for Running the Compiler under OS/390 with the Global Optimization Phase illustrates how to run the compiler under OS/390 while including the global optimization phase.


Sample JCL for Running the Compiler under OS/390 with the Global Optimization Phase
//COMPILE JOB job card information //*------------------------------------------------------------ //* EXAMPLE JCL FOR COMPILATION. //* REPLACE GENERIC NAMES AS APPROPRIATE. //*------------------------------------------------------------ //* SYNTAX ANALYSIS PHASE //*------------------------------------------------------------ //STEP1 EXEC PGM=LC1370,REGION=1024K, // PARM='-R P: -M !X: O: -IN -IL -IC8' //STEPLIB DD DISP=SHR,DSN=compiler.library // DD DISP=SHR,DSN=runtime.library //SYSLIB DD DISP=SHR,DSN=standard.macro.library //H DD DISP=SHR,DSN=your.macro.library //SYSPRINT DD SYSOUT=class //SYSTERM DD SYSOUT=class //SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(1,1)), // DISP=(NEW,PASS), // DSN=&&QUADS //SYSIN DD DISP=SHR,DSN=your.source.library(member) //* /* //*------------------------------------------------------------ //* GLOBAL OPTIMIZATION PHASE //*------------------------------------------------------------ //STEP2 EXEC PGM=LCGO,REGION=2048K,COND=(4,LT), // PARM='-IN -IL -IC8' //STEPLIB DD DISP=SHR,DSN=compiler.library // DD DISP=SHR,DSN=runtime.library //SYSPRINT DD SYSOUT=class //SYSTERM DD SYSOUT=class //SYSUT1 DD DSN=&&QUADS,DISP=(OLD,PASS) //SYSUT3 DD UNIT=SYSDA,SPACE=(CYL,(1,1)), // DISP=(NEW,PASS),DSN=&&NEWQ //* /* //*------------------------------------------------------------ //* CODE GENERATION PHASE //*------------------------------------------------------------ //STEP3 EXEC PGM=LC2370,REGION=1024K,COND=(4,LT) //STEPLIB DD DISP=SHR,DSN=compiler.library // DD DISP=SHR,DSN=runtime.library //SYSPRINT DD SYSOUT=class //SYSTERM DD SYSOUT=class //SYSUT1 DD DISP=(OLD,PASS),DSN=&&NEWQ //SYSLIN DD DISP=OLD,DSN=your.object.library(member) //


Running the compiler without the global optimization phase

The sample JCL in Sample JCL for Running the Compiler under OS/390 without the Global Optimization Phase illustrates how to run the compiler under OS/390 without the global optimization phase.


Sample JCL for Running the Compiler under OS/390 without the Global Optimization Phase
//COMPILE JOB job card information //*------------------------------------------------------------ //* EXAMPLE JCL FOR COMPILATION. //* REPLACE GENERIC NAMES AS APPROPRIATE. //*------------------------------------------------------------ //* SYNTAX ANALYSIS PHASE //*------------------------------------------------------------ //STEP1 EXEC PGM=LC1370,REGION=1024K, // PARM='-R P: -M !X:' //STEPLIB DD DISP=SHR,DSN=compiler.library // DD DISP=SHR,DSN=runtime.library //SYSLIB DD DISP=SHR,DSN=standard.macro.library //H DD DISP=SHR,DSN=your.macro.library //SYSPRINT DD SYSOUT=class //SYSTERM DD SYSOUT=class //SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(1,1)), // DISP=(NEW,PASS), // DSN=&&QUADS //SYSIN DD DISP=SHR,DSN=your.source.library(member) //* /* //*------------------------------------------------------------ //* CODE GENERATION PHASE //*------------------------------------------------------------ //STEP2 EXEC PGM=LC2370,REGION=1024K,COND=(4,LT) //STEPLIB DD DISP=SHR,DSN=compiler.library // DD DISP=SHR,DSN=runtime.library //SYSPRINT DD SYSOUT=class //SYSTERM DD SYSOUT=class //SYSUT1 DD DISP=(OLD,PASS),DSN=&&QUADS //SYSLIN DD DISP=OLD,DSN=your.object.library(member) //


Running the compiler using the debug option

The sample JCL in Sample JCL for Running the Compiler under OS/390 with debug option illustrates how to run the compiler under OS/390 using the debug option. For more information see the SAS/C Debugger User's Guide and Reference.


Sample JCL for Running the Compiler under OS/390 with debug option
//COMPILE JOB job card information //*------------------------------------------------------------ //* EXAMPLE JCL FOR COMPILATION. //* REPLACE GENERIC NAMES AS APPROPRIATE. //*------------------------------------------------------------ //* SYNTAX ANALYSIS PHASE //*------------------------------------------------------------ //STEP1 EXEC PGM=LC1370,REGION=1024K, // PARM='-D -R P: -M !X:' //STEPLIB DD DISP=SHR,DSN=compiler.library // DD DISP=SHR,DSN=runtime.library //SYSLIB DD DISP=SHR,DSN=standard.macro.library //H DD DISP=SHR,DSN=your.macro.library //SYSPRINT DD SYSOUT=class //SYSTERM DD SYSOUT=class //SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(1,1)), // DISP=(NEW,PASS), // DSN=&&QUADS //SYSUT2 DD UNIT=SYSDA,SPACE=(CYL,(1,1)), // DISP=(NEW,PASS), // DSN=&&SDIF //SYSIN DD DISP=SHR,DSN=your.source.library(member) //* /* //*------------------------------------------------------------ //* CODE GENERATION PHASE //*------------------------------------------------------------ //STEP2 EXEC PGM=LC2370,REGION=1024K,COND=(4,LT) //STEPLIB DD DISP=SHR,DSN=compiler.library // DD DISP=SHR,DSN=runtime.library //SYSPRINT DD SYSOUT=class //SYSTERM DD SYSOUT=class //SYSUT1 DD DISP=(OLD,PASS),DSN=&&QUADS //SYSUT2 DD DISP=(OLD,PASS),DSN=&&SDIF //SYSDBLIB DD DISP=OLD,DSN=your.debugger.library //SYSLIN DD DISP=OLD,DSN=your.object.library(member) //


Chapter Contents

Previous

Next

Top of Page

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