Programmer's Report: Using the SAS/C(r) Standard C++ Library Release 6.50 F ----------------------------------------------------------------------------------------- Table of Contents Introduction Online Documentation General Information for all Platforms Chapter Contents Overview of Standard C++ Library Components SAS/C Compiler and SAS/C C++ Translator Options for Standard C++ Library Using Standard C++ Library Support on MVS Using Standard C++ Library Support on CMS Using Standard C++ Library Support on Unix with the SAS/C Cross-Platform Compiler Using Standard C++ Library Support on the PC with the SAS/C Cross-Platform Compiler ----------------------------------------------------------------------------------------- Introduction The SAS/C Standard C++ Library is a feature designed to extend the capabilities of the SAS/C C++ Development System. This library was built using Rogue Wave's popular Standard C++ Library. The SAS/C Standard C++ Library provides a custom build of Rogue Wave's implementation of the emerging ISO/ANSI Standard C++ Library, including the Standard Template Library. The Standard C++ Library is currently being developed by ISO/ANSI standards committees and within a few years all ANSI-conforming C++ compilers will deliver a standard set of classes and libraries. The Rogue Wave Standard C++ Library avoids encapsulation and uses almost no inheritance, making it a highly efficient tool that can be used whenever performance is a major concern. Online Documentation With Release 6.50, we are continuing our move to online documentation. You will find the following documentation on the CD-ROM titled SAS/C OnlineDocTM, Release 6.50, which is included with the SAS/C software distribution package: . Introducing SAS/C ? Software, Release 6.50 . SAS/C ? Compiler and Library User's Guide, Fourth Edition, Release 6.00 . SAS/C ? C++ Development System User's Guide, Release 6.50 . SAS/C ? Software Diagnostic Messages, Release 6.50 . SAS/C ? Software: Changes and Enhancements, Release 6.50 . A Guide for the SAS/C Compiler Consultant, Release 6.50 . SAS/C ? Library Reference, Third Edition, Volume 1, Release 6.00 . SAS/C ? Library Reference, Third Edition, Volume 2, Release 6.00 . SAS/C ? Cross-Platform Compiler and C++ Development SystemUser's Guide, Release 6.50 . Standard C++ Library Rogue Wave titles: Standard C++ Library General User's Guide - OEM Edition Standard C++ Library Class Reference The CD is readable on PC, Macintosh, and UNIX platforms. It is organized as indicated below: Directory Contains overview Introducing SAS/C ? Software, Release 6.50. changes The Release 6.50 changes and enhancements technical report. clug The compiler and library user's guide. cplus C++ Development System user's guide. diag Diagnostic messages manual. techsup The compiler consultant's guide. lr1 and lr2 The library reference manual. cross The cross-platform compiler user's guide. rogue Documentation for the SAS/C Standard C++ Library. common Graphic files in the SAS/C documentation. postscript Postscript files for each online book. ----------------------------------------------------------------------------------------- General Information for all Platforms Chapter Contents . Overview of Standard C++ Library Components . SAS/C and SAS/C++ Compiler Options for Standard C++ Library . Using Standard C++ Library Support on MVS . Using Standard C++ Library Support on CMS . Using Standard C++ Library Support on UNIX with the SAS/C Cross-Platform Compiler . Using Standard C++ Library Support on the PC with the SAS/C Cross-Platform Compiler Overview of Standard C++ Library Components The SAS/C Standard C++ Library feature consists of the following components: . header file library This library consists of Rogue Wave's Standard C++ Library Includes and should be included in SAS/C Standard C++ Library applications. . archive library This library consists of Rogue Wave's Standard C++ Library and is used by the SAS/C pre-linker (COOL) to resolve Standard C++ Library external references. . sample library This library consists of Rogue Wave's Standard C++ Library samples. These samples demonstrate using the Standard C++ Library Standard Template Library (STL) class libraries and class libraries for string, numeric, and mathematical processing. SAS/C Compiler and SAS/C C++ Translator Options for Standard C++ Library To use the SAS/C Standard C++ Library feature, you must have licensed the SAS/C Compiler and the SAS/C C++ Development System products. Please refer to the documentation that you received with the SAS/C Compiler and SAS/C C++ Development System products for a complete description of options and features that may be helpful in using the SAS/C Standard C++ Library feature. The SAS/C Compiler and SAS/C C++ Development System products provide a significant number of options to customize the format for generated object code. The emerging C++ standard has also required additional options to control the compilation process. The SAS/C Compiler and Library User's Guide provides a complete list and description of compiler options. The SAS/C C++ Development System Users Guide provides a complete list and description of the C++ translator options. You must specify at least the following set of C++ translator and compiler options when compiling your Standard C++ Library applications: rent, refdef, autoinst, and sname. Reentrancy The Standard C++ Library library was created with the rent compiler option. To properly link with the library, you must specify the rent option when compiling your Standard C++ Library application. Automatic Template Instantiation The autoinst option allows the C++ translator to automatically instantiate template functions and static data members of template classes when their definitions are needed. Reference Definition The refdef option causes the compiler to generate code that forces the use of the strict reference-definition model for reentrant external variables. Section Name The sname option defines the section name used by the translator and compiler. The name cannot be longer than seven characters. Using Standard C++ Library Support on MVS To use the Standard C++ Library support on MVS you will need to make the header files and the Standard C++ archive available to the C++ translator, specify the appropriate compiler options, and make the Standard C++ Library library available when you link your application program. The Standard C++ Library header file library on MVS is named sasc.RW.MACLIBC. Use this header file library in addition to the SAS/C standard C and C++ header file library sasc.MACLIBC. The Standard C++ Library archive library is named sasc.RW.LIBSTD.A. Use this archive library in addition to the standard C++ archive, sasc.C650.LIBCXX.A. The following sample JCL calls a procedure, RWCLG, that demonstrates how to compile, link, and execute a simple Standard C++ Library application program. Lines marked with <- Verify contain values you need to change for your specific installation. Change the value, sasc, to indicate the location of your installation of SAS/C Software products. //jobname JOB .... <== VERIFY //* //* SASCHLQ = Installation location for the SAS/C++ Compiler //* product //* // SET SASCHLQ=sasc.c650 <== VERIFY //* // JCLLIB ORDER=&SASCHLQ..PROCLIB //******************************************************** //******** RWCLG PROC DOES A COMPILE LINK AND GO ********* //******************************************************** //RWCLG PROC MEMBER=,SNAME=,XPARM= //CLG EXEC PROC=LCXXCLG, // PARM.X='&XPARM SNAME(&SNAME) RENT AUTOINST REFDEF' //* //X.SYSTRIN DD DISP=SHR,DSN=&SASCHLQ..RW.SAMPLE(&MEMBER) //X.H DD DISP=SHR,DSN=&SASCHLQ..RW.SAMPLE //X.SYSLIB DD // DD DISP=SHR,DSN=&SASCHLQ..RW.MACLIBC //X.SYSTROUT DD DSN=&&TROUT,SPACE=(TRK,(100,50)), // DISP=(NEW,PASS),UNIT=DISK //X.SYSLIN DD DSN=&&OBJECT,SPACE=(3200,(20,20)), DISP=(NEW,PASS), // UNIT=DISK,DCB=(RECFM=FB,LRECL=80) //* //LKED.SYSARLIB DD DISP=SHR,DSN=&SASCHLQ..RW.LIBSTD.A // DD DISP=SHR,DSN=&SASCHLQ..LIBCXX.A //LKED.SYSLMOD DD DSN=&&LOADMOD(MAIN),DISP=(,PASS),UNIT=DISK, // SPACE=(1024,(50,50,1)) //* //SYSTMP01 DD DSN=&&TMP1,UNIT=SYSDA,SPACE=(TRK,(100,50)) //SYSTMP02 DD DSN=&&TMP2,UNIT=SYSDA,SPACE=(TRK,(100,50)) // PEND //* //******************************************************** //* NOW CALL PROC WITH PARAMETERS REQUIRED ************* //******************************************************** //BINDER EXEC RWCLG, // MEMBER=RWCX001,SNAME=BINDER The SAS/C Standard C++ Library feature contains many samples that demonstrate how to use the Standard C++ Library library functions. The Standard C++ Library samples are in sasc.RW.SAMPLE. Using Standard C++ Library Support on CMS To use the Standard C++ Library support on CMS you will need to make the header file available to the C++ translator, specify the appropriate compiler options, and make the Standard C++ Library library available when you link your application program. The Standard C++ Library header file library on CMS is named RW MACLIB. You make this header file available in addition to the SAS/C standard C and C++ header files by using the CMS GLOBAL MACLIB command or by using the CXXMACLIBS GLOBALV environment variable. An example of the CMS GLOBAL maclib command would look like this: GLOBAL MACLIB LCXX370 LC370 RW An example of the GLOBALV command to set the CXXMACLIBS environment variable would look like this: GLOBALV SELECT LC370 SETLP CXXMACLIBS LCXX370 LC370 RW The command to invoke the C++ translator would then look like this: LCXX source_filename (AUTOINST REFDEF RENT SNAME sample1 The Standard C++ Library archive library on CMS is named LIBSTD A. To link a Standard C++ Library program with the SAS/C COOL pre-linker use this archive as input to COOL like this: COOL object_filename LIBSTD (CXX The SAS/C Standard C++ Library feature contains samples that demonstrate how to use the Standard C++ Library library functions. The Standard C++ Library samples are named RWSAMP MACLIB. Note: Use the DEFINE STORAGE command if you need to increase your virtual machine size and use the SET LDRTBLS command to increase the number of loader tables available to the linker if needed. Using Standard C++ Library Support on Unix with the SAS/C Cross-Platform Compiler The SAS/C Standard C++ Library support was installed in the same installation location or directory as the SAS/C Compiler and SAS/C C++ Development System products. Contact your installation coordinator if you need help locating the installation directory for the SAS/C products at your site. Compiling and Linking an Application with Standard C++ Library Since the Standard C++ Library support is installed in the same location as the other SAS/C products, you don't have to explicitly specify where the Standard C++ Library header files are located. You can just invoke the compiler driver and specify the appropriate compiler options. For example, to compile and pre-link a sample program named accum.cxx you would enter the following command: sasCC370 -Kautoinst -Krefdef -Krent -Ksname=accum install- dir/lib/libstd.a installdir/samples/rw/accum.cxx Using Standard C++ Library Support on the PC with the SAS/C Cross-Platform Compiler The SAS/C Standard C++ Library feature was installed in the same installation location or directory as the SAS/C Compiler and SAS/C C++ Development System products. Contact your installation coordinator if you need help locating the installation directory for the SAS/C products at your site. Compiling and Linking an Application with Standard C++ Library Since the Standard C++ Library support is installed in the same location as the other SAS/C products, you don't have to explicitly specify where the Standard C++ Library header files are located. You should be able to just invoke the compiler driver and specify the appropriate compiler options. For example, to compile and pre-link the sample Standard C++ Library program named accum.cpp you would enter the following command: sascc370 -Kautoinst -Krefdef -Krent -Ksname=accum install- dir\lib\libstd.a installdir\samples\rw\accum.cpp