Chapter Contents |
Previous |
Next |
Using the SAS/C Cross-Platform Compiler and C++ Development System |
The following sections provide examples of different DOS shell batch files used to generate compiled object code and prelinked output for final execution on the mainframe. See Using SAS/C C and C++ under the Microsoft Visual C++ IDE for a description of similar objectives under Microsoft Visual C++ IDE.
Compiling C and C++ Source Code |
The following sample compile batch file will accept
as input a
.c
file and compile the code to produce only an object
deck (
-c
), allowing reentrant modification of static and
external data (
-Krent
), and defining a section name as the source
code filename (
-Ksname
). (Note the section name must be seven characters
or less.) The
-v
option specifies that both the driver messages
and the command lines that execute each phase of the cross-platform compiler
are echoed to the
%LOG%
file. If the source file is not in the current working directory, the quoted,
qualified pathname should be entered as the second command-line argument.
@echo off set NAME=%1 set PATHNAME= if NOT '%2'==" set PATHNAME=%2\ set SOURCE=%PATHNAME%%NAME%.c set OBJECT=%NAME%.o set LOG=%NAME%.clg set C_OPTS=-c -v -Krent -Ksname=%NAME% erase %LOG% erase %OBJECT% sascc370 %C_OPTS% %SOURCE% -o %OBJECT% > %LOG% echo Done with %NAME%.
Following is the correct syntax to invoke this sample compile.bat file:
compile sourcename [pathname]
For example, to compile the file
D:\Program
Files\sasc\samples\c\ftoc.c
and produce
ftoc.o
in the current working
directory, enter the following command:
compile ftoc "d:\Program Files\sasc\samples\c"
where
ftoc
on the command line is the source
code filename without the
.c
extension.
At installation, the PATH environment variable is prefixed
to include the location of the
sascc370
driver (
installdir\host\wnt\bin
), so the driver name in these
batch files should not require an explicit pathname.
Prelinking Object Code |
The following sample prelink
batch file accepts as input the previously compiled object code filename (without
the
.o
extension) and produces prelinked output from
cool
. The
-v
option specifies that any driver messages, and
the command lines that execute
cool
, are echoed to the
%LOG%
file. If the object file
is not in the current working directory, the quoted, qualified pathname should
be entered as the second command-line argument.
@echo off set NAME=%1 set PATHNAME= if NOT '%2'==" set PATHNAME=%2\ set OBJECT=%PATHNAME%%NAME%.o set OUTPUT=%NAME% set LOG=%NAME%.llg set L_OPTS=-v erase %LOG% erase %OUTPUT% sascc370 %L_OPTS% %OBJECT% -o %OUTPUT% > %LOG% echo Done with %NAME%.
Following is the correct syntax to invoke this sample
link.bat
file:
link objectname [pathname]
For example, to prelink the object file
ftoc.o
and generate
ftoc
, enter the following command:
link ftoc
where
ftoc
on the command line is the object code filename
without the
.o
extension.
Building Source Code |
Alternatively, to compile and prelink source code in one
step, you could execute the following batch file. The
sascc370
driver executes the SAS/C C and C++ Cross-Platform compiler, which
produces prelinked output generated by
cool.
In the following
example, the compiler options specify reentrant code, extended names processing
(
-Kextname
), a section name, run-time type identification (
-Krtti
),
and instantiation of class templates (
-Kautoinst
). A quoted include pathname is added for user-defined
header files. The command line that executes each phase of the cross-platform
compiler is displayed in the
%LOG%
file.
@echo off set NAME=%1 set PATHNAME= if NOT '%2'==" set PATHNAME=%2\ set OUTPUT=%NAME% set LOG=%NAME%.log set BLD_OPTS=-v -Krent -Kextname -Ksname=%NAME% -Krtti -Kautoinst set INCL= -I"d:\Program Files\sasc\samples\h" erase %LOG% erase %OUTPUT% sascc370 %BLD_OPTS% %INCL% %SOURCE% -o %OUTPUT% > %LOG% echo Done with %NAME%.
Following is the correct syntax to invoke this sample
build.bat
file:
build sourcename [pathname]
For example, to compile and prelink the file
d:\Program Files\sasc\samples\cxx\tsttmpl.cxx
enter the following command:
build.bat tsttmpl "d:\Program Files\sasc\samples\cxx"
where
tsttmpl
on the command line is the C++ source code
filename without the
.cxx
extension. This method produces
two files. In this example, the compiler generates the object file
tsttmpl.o
and the prelinker produces the prelinked output file
tsttmpl
.
The output
tsttmpl.log
file should
look something like the example in Example log file:
SAS/C Compiler Driver V6.50.01 Copyright (C) 1998 SAS Institute Inc. set INCLUDE370='d:\Program Files\SASC\Include' "d:\Program Files\SASC\host\wnt\bin\cxx" -Adigraph1 -Adigraph2 -DCROSS370=l -XA -Hu '-r' '-Arrti' "-Id:\Program Files\Sasc\Samples\h" '-MC:\TEMP\sascca00344.1.ai' '-mtsttmpl' "d:\program files\sasc\samples\cxx\tsttmpl.cxx" "C:\TEMP\sascca00344.1.c" "d:\Program Files\SASC\host\wnt\bin\lc1" -dCROSS370=1 -cd -hu -n! '-r' '-n!' "-id:\Program Files\Sasc\Samples\h" -cxx -d__CXX_PRIMARY__=1 -q011=1 '-ststtmpl' -xc "-oC:\TEMP\sascca00344.1.q" "C:\TEMP\sascca00344.1.c SAS/C Release 6.50.01 (Target 370 Cross Compiler) Copyright (c) 1998 by SAS Institute Inc. All Rights Reserved. *** No errors; No warnings; No user suppressed warnings "d:\Program Files\SASC\host\wnt\bin\lc2" "-oC:\TEMP\sascca00344.1.o" "C:\TEMP\sascca00344.1.q" SAS/C Compiler (Phase 2) 6.50.01 Copyright (c) 1998 by SAS Institute Inc. All Rights Reserved. "d:\Program Files\SASC\host\wnt\bin\lc1" -dCROSS370=1 -cd -hu -n! '-r' '-n!' "-id:\Program Files\Sasc\Samples\h" -cxx -d__CXX_SECONDARY_0__=1 -q011=2 '-q012=@%TEMPL' -xc "-oC:\TEMP\sascca00344.1.q" "C:\TEMP\sascca00344.1.c" SAS/C Release 6.50.01 (Target 370 Cross Compiler) Copyright (c) 1998 by SAS Institute Inc. All Rights Reserved. *** No errors; No warnings; No user suppressed warnings "d:\Program Files\SASC\host\wnt\bin\lc2" "-oC:\TEMP\sascca00344.2.o" "C:\TEMP\sascca00344.1.q" SAS/C Compiler (Phase 2) 6.50.01 Copyright (c) 1998 by SAS Institute Inc. All Rights Reserved. "d:\Program Files\SASC\host\wnt\bin\lc1" -dCROSS370=1 -cd -hu -n! '-r' '-n!' "-id:\Program Files\Sasc\Samples\h" -cxx -d__CXX_SECONDARY_1__=1 -q011=3 '-q012=@%TEMPL' -xc "-oC:\TEMP\sascca00344.1.q" "C:\TEMP\sascca00344.1.c" SAS/C Release 6.50.01 (Target 370 Cross Compiler) Copyright (c) 1998 by SAS Institute Inc. All Rights Reserved. *** No errors; No warnings; No user suppressed warnings "d:\Program Files\SASC\host\wnt\bin\lc2" "-oC:\TEMP\sascca00344.3.o" "C:\TEMP\sascca00344.1.q" SAS/C Compiler (Phase 2) 6.50.01 Copyright (c) 1998 by SAS Institute Inc. All Rights Reserved. "d:\Program Files\SASC\host\wnt\bin\sheller" -c -o tsttmpl.o "@C:\TEMP\sascca00344.1.shell" "d:\Program Files\SASC\host\wnt\bin\cool" -o "tsttmpl" -L"d:\Program Files\SASC" tsttmpl.o "d:\Program Files\SASC"\lib\libcxx.a "d:\Program Files\SASC"\lib\mvs\libc.a SAS/C (R) C Object code Pre-Linker Release 6.50.01 Copyright (c) 1998 by SAS Institute Inc. All Rights Reserved. cool: Note 1010: Pre-Linking completed with return code = 0
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.