z/OS C/C++ V1R2 Standard C++ Library Features

The following information describes features, which are provided by z/OS C/C++ Version 1 Release 2 for the Standard C++ Library, and are in addition to the support described in the Standard C++ Library information by P.J. Plauger.

Enhanced ASCII Functionality Support

The z/OS Server and its predecessor OS/390 are EBCDIC platforms. Porting applications from ASCII platforms to the z/OS Server is a complex task. Differences in ASCII and EBCDIC encoding make it impossible to exploit encoding properties for performance and maintain a single source base for an application that should run on an ASCII platform and z/OS Server. As a solution to this problem, a new facility on the z/OS Server allows ASCII applications to run as if they were running on an ASCII-based UNIX platform.  This facility is known as enhanced ASCII functionality. It is only implemented for C and C++ applications.

Enhanced ASCII functionality allows applications developed on ASCII platforms to run on the z/OS V1R2 Server with minimal changes, if any. Although the compiler does not process source code that is encoded in ASCII, it provides a facility that allows character constants and string literals to be converted to ASCII automatically.  It also marks each compilation unit of a running ASCII application with an ASCII flag. This allows the C/C++ Run Time Library (C/C++RTL) to recognize a running program as an ASCII program. The C/C++RTL, which includes the Standard C++ Library, provides standard library functions which allow ASCII parameters and return ASCII values. In addition, the C/C++RTL provides ASCII locales for running ASCII programs.

Applications can either be ASCII or EBCDIC but not both, as there is no bimodal support.

Building an ASCII application is as simple as specifying an ASCII compiler option. When the ASCII option is specified, the compiler uses ISO8859-1 as the default code page to which character constants and string literals are converted and turns on the CONVLIT(,WCHAR) suboption with Unicode as the wide character encoding.

Classes and functions from the Standard C++ Library that are sensitive to character encoding are provided in both ASCII and EBCDIC versions and are packaged in a common DLL.

Compile Options

Two compiler options are relevant for enhanced ASCII functionality in the Standard C++ Library: ASCII and CONVLIT. Both are described in the z/OS C/C++ User's Guide.

Pragmas

Two pragmas, #pragma convlit(suspend) and #pragma convlit(resume), are relevant to the ASCII support in the Standard C++ Library. The pragmas are described in the C/C++ Language Reference.

Feature Test Macros

__CHARSET_LIB is a new macro that indicates the character encoding used in the compilation. Both C and C++ compilers predefine this macro. When the ASCII compiler option is specified, the compiler assigns a value of 1 to this macro, otherwise it assigns a value of 0.

PDS Support in the Standard C++ Library

To access a partitioned dataset (PDS) using the Standard C++ Library, the z/OS C/C++ V1R2 user can append the file attributes to ios_base::openmode when invoking the fstream, ifstream or ofstream constructor or open method (for example, "wb+" + ", " + "recfm=F, lrecl=80" => "wb+, recfm=F, lrecl=80").

Note: If you do not need to specify recfm or lrecl, you do not need to use the additional parameter to access a PDS.

All fopen() mode parameter values are supported except type=record. Specifying type=record will result in a failure, and errno is set. Any other validation of the resulting fopen() mode string is performed by fopen().

Failure of the open() functions is indicated by a return code of 0. For the file name of both the base and overloaded constructors and open() member functions, ddnames are accepted.

Large File Support in the Standard C++ Library

To access hierarchical file system (HFS) files that are greater than 2 GB in size with the Standard C++ Library, the z/OS C/C++ V1R2 user is required to compile the application with the compile option LONGLONG and define the _LARGE_FILES feature test macro before any headers are included. File size and offset fields will be enlarged to 63 bits in width.

Users who access a large file without the LONGLONG compile option and DEFINE(_LARGE_FILES) will get unexpected results on a large file that has more than 2GB of data.

FLOAT(HEX) Support and the complex Library

z/OS V1R2 supports the S/390 hexadecimal floating-point format for the complex<> library so that users with hexadecimal (HEX) legacy data can use the Standard C++ complex numbers library.

To use a HEX floating-point number with the Standard C++ Library, the user must compile their code with the FLOAT(HEX) option when building their application. Note: there is a difference between HEX and IEEE. An IEEE floating-point number supports infinity (INF) and not-a-number (NAN) while HEX does not. In a situation where a HEX floating-point number is used and INF or NAN arise, one of the following will happen:

It is the user's responsibility to test for these conditions.

FLOAT(HEX) Support and the numeric_limits Library

numeric_limits<> stores the platform-specific limits for various types, including float, double and long double. The user will notice different limits for the HEX and IEEE floating-point formats. Most noticeably, the following properties of numeric_limits<float>, numeric_limits<double>, and numeric_limits<long double> are different for HEX:

has_infinity          = false,
has_quiet_Nan         = false,
has_signaling_Nan     = false,
is_iec559             = false,
tinyness_Before       = false,
rount_style           = round_toward_zero

z/OS V1R2 Standard C++ Library Packaging

The following information describes Standard C++ Library packaging features for z/OS V1R2.

System Header Files

All Standard C++ Library header files and templates are provided in the standard set of PDS datasets and HFS directories. Template files with the suffix .t are provided in the new PDS dataset SCEEH.T, while the header files without a suffix are provided in the new PDS dataset SCEEH. All of these files are also provided in the /usr/include HFS directory.

DLL/Sidedeck Name

The Standard C++ Library DLL is provided in the SCEERUN2 data set. The name of the DLL is C128. Only the XPLINK version of the DLL is provided. The corresponding sidedeck file is provided in the SCEELIB dataset as member C128.

Object Library

There is no support for static linking of Standard C++ Library to end user applications, so no object library is provided.

Application Program Interface

Application programs are provided with Standard C++ Class Library and Standard Template Library interfaces defined in the ISO/IEC 14882:1998(E) standard.

Restrictions

The Standard C++ Library is only provided as an XPLINK DLL. This does not preclude non-XPLINK applications from calling interfaces in the DLL, because non-XPLINK applications calling XPLINK DLLs are supported. Bridging non-XPLINK applications and XPLINK DLLs has performance implications. If performance is a concern, users should migrate the application to XPLINK. Applications calling XPLINK DLLs are supported by specifying the Language Environment run-time option XPLINK(ON) when the intial program is a non-XPLINK application.

Migration/Coexistence

The Standard C++ Library is a new z/OS V1R2 Server feature. To exploit this new feature, users must migrate their applications. If migration is not desirable, users can continue to use the IBM Open Class Library. The Standard C++ Library coexists with the IBM Open Class Library and the STLPort.