Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

5 Using the Standard C++ Library

• User Documentation on page 5-3


• Features of the Standard C++ Library (VERSION3) on page 5-3
• Contents of the Standard C++ Library on page 5-4
° VERSION3 on page 5-4
° VERSION2 on page 5-5
° VERSION1 on page 5-5
• Installation Notes for VERSION3 on page 5-6
° Using Header Files With VERSION3 on page 5-7
• Installation Notes for VERSION2 on page 5-7
° Examples of VERSION2 Headers on page 5-8
° VERSION2 Standard C++ Library Example Files on page 5-9
• Compiling and Linking in the OSS Environment on page 5-12
• Pragmas for the Standard C++ Library on page 5-12
• Using the Neutral C++ Dialect on page 5-13
Three versions of the Standard C++ Library are available on NonStop systems, as
listed in Table 5-1 on page 5-2.

Caution. All modules of an application must be built using the same version of the Standard
C++ Library dialect. The native linkers and the NonStop OS perform version checking.
Attempting to mix versions will yield an error or a warning at link time, and a run-time error at
load time.

Beginning with the G06.20 and H06.01 RVUs, VERSION3 is the default native C++
run-time library. For more details about the default language dialect, see VERSION3
on page 13-110. For information about all available libraries, also see Table 16-5 on
page 16-15 and Table 17-5 on page 17-14.

HP C/C++ Programmer’s Guide for NonStop Systems —429301-010


5 -1
Using the Standard C++ Library

Table 5-1. Versions of the Standard C++ and C++ Run-Time Libraries
Product
Version Number Description
TNS/R programs
VERSION1 T9227 C++ run-time library
NonStop S-series Separate libraries for Guardian and OSS:
systems only ZCPLGSRL and ZCPLOSRL, respectively
T2824 Common header files for all C++ versions
VERSION2 T5895 Standard C++ library, Rogue Wave Software version
1.31, file ZRWSLSRL
T0179 C++ run-time library, file ZCPLSRL
T8473 Tools.h++ version 7 library, file ZTLHSRL
T5894 Tools.h++ version 7 header files
T2824 Common header files for all C++ versions
VERSION3 T2767 Standard C++ library ISO/IEC (Dinkumware)
combined with the C++ run-time library, file ZSTLSRL
T2824 Common header files for all C++ versions
TNS/E programs
VERSION2 T2832 VERSION2 C++ standard library that contains classes,
data, and functions that are not shareable with their
VERSION3 counterpart or do not exist in VERSION3,
file ZCPP2DLL
T2834 Tools.h++ version 7 header files
T2835 Tools.h++ version 7 library, file ZTLH7DLL
T2831 Common library for VERSION2 and VERSION3, file
ZCPPCDLL
T2830 Common header files for all C++ versions
VERSION3 T2831 Common library for VERSION2 and VERSION3, file
ZCPPCDLL
T2833 VERSION3 C++ standard library that contains classes,
data, and functions that are not shareable with their
VERSION2 counterpart or do not exist in VERSION2,
file ZCPP3DLL
T2830 Common header files for all C++ versions

HP C/C++ Programmer’s Guide for NonStop Systems —429301-010


5 -2
Using the Standard C++ Library User Documentation

User Documentation
Available using the HP NonStop Technical Library (NTL) software:
• VERSION3: Standard C++ Library Reference ISO/IEC (VERSION3)

Caution. The VERSION3 documentation contains descriptions of an underlying C library that


is not the same in every case as the C library supported on HP NonStop systems. The
descriptions of those C functions might not apply to the NonStop C run-time library.

• VERSION2: Standard C++ Library User Guide and Tutorial and the
Standard C++ Library Class Reference
• VERSION1: AT&T C++ Reference, Release 3 or The Annotated C++ Reference
Manual by Margaret Ellis and Bjorne Stroustrup (these books are not available on
NTL).

Features of the Standard C++ Library


(VERSION3)
VERSION3 Feature Advantages
C++ Standard Compliant The language and library provide full compliance with the
ANSI/ISO C++ Standard, with very few exceptions. ANSI/ISO
compliance simplifies porting applications to the NonStop
platform.
Improved exception Type checking for throws and catches has been improved and
handling is tighter than for VERSION2. Type IDs (names beginning with
__TID_) are used to match throws and catches. The "const-
ness" of the catch must match that of the throw. For example, if
"goodbye world" is thrown, the catch must expect a const
char *.
Template support Templates are now fully supported, including templates as
parameters to templates, and explicit qualification of templates.
Support for DLLs Beginning with G06.20, both VERSION2 and VERSION3
libraries fully support using dynamic-link libraries (DLLs). You
must use the latest libraries in a DLL environment; VERSION1
does not support the use of DLLs.
Floating point Both IEEE_FLOAT and TANDEM_FLOAT are supported by
VERSION2 and VERSION3. All object files that make up a
running process should be consistent in the use of floating-
point type. VERSION1 does not support IEEE_FLOAT.
Pthreads To ensure that the same thread is used to throw and catch an
exception, Pthreads and the C++ VERSION2 or VERSION3
run-time libraries store some state information in variables in
the C++ library. This functionality has been implemented in
both VERSION3 and VERSION2.

HP C/C++ Programmer’s Guide for NonStop Systems —429301-010


5 -3
Using the Standard C++ Library Contents of the Standard C++ Library

VERSION3 Feature Advantages (continued)


Migration tool To help customers move from C++ VERSION2 to C++
VERSION3, the migration tool generates warnings in the listing
file where potential problems are found. The
MIGRATION_CHECK pragma is described in
MIGRATION_CHECK on page 13-62, and its output is
described in Appendix F, MIGRATION_CHECK Messages.
Hash tables Although not part of the standard, HASH_SET,
HAS_MULTISET, HASH_MAP, and HASH_MULTIMAP have
been implemented in the HP NonStop C++ implementation.
Support for the neutral Although not part of the standard, HP provides the features
C++ dialect on NonStop described in Using the Neutral C++ Dialect on page 5-13.
NS-series systems These features take advantage of the repackaging of C++
objects on NonStop NS-series systems into three library files
so that a limited ability exists to create libraries that are not
version dependent.

Contents of the Standard C++ Library


VERSION3
For VERSION3, the Standard C++ Library ANSI/ISO/IEC is a port of the Dinkumware
C++ Library, a conforming implementation of the Standard C++ library by P.J. Plauger.
The library enforces the ISO/IEC IS 14882:1998(E) standard for C++, plus a number of
fixes ratified by the C++ Standards Committee and documented in corrigenda before
the NonStop VERSION3 code was developed and finalized.
A C++ program can call on a large number of functions from the Dinkum C++ Library
that perform essential services such as input and output. These functions also provide
efficient implementations of frequently used operations. Numerous function and class
definitions accompany these functions to help you make better use of the library.
Information about the Standard C++ library can be found in the descriptions of the C++
library headers that declare or define library entities for the program. Also see the
documentation for the library, the Standard Compliant C++ Library Reference, available
on the NonStop user CD using the HP NonStop Technical Library (NTL).
There are two broad subdivisions of the Standard C++ headers: streams and the
standard template library (STL).
The VERSION3 Standard C++ Library contains 36 C++ headers:
<algorithm> <bitset> · <complex> <deque> <exception> <fstream> ·
<functional> <hash_map> <hash_set> <iomanip> <ios> <iosfwd> ·
<iostream> <istream> <iterator> <limits> <list> <locale> ·
<map> <memory> <new> <numeric> <ostream> <queue> ·
<set> <slist> <sstream> <stack> <stdexcept> <streambuf> ·
<string> <strstream> <typeinfo> <utility> <valarray> <vector>

HP C/C++ Programmer’s Guide for NonStop Systems —429301-010


5 -4
Using the Standard C++ Library VERSION2

Using VERSION3 on Guardian environment, you should use the full name of the
standard headers, without truncating the name or using a .h file extension. The
NonStop system automatically performs truncation as necessary.
HP recommends that you also use the CPATHEQ pragma to specify the SLMAP file as
described in Pragmas for the Standard C++ Library on page 5-12. SLMAP contains
specific truncation rules for the header names that do not fit the standard.
These 18 C-name headers are also part of the library, required as part of the ANSI /
ISO C++ Standard:
<cassert> <cctype> <cerrno> <cfloat> <ciso646> <climits> ·
<clocale> <cmath> <csetjmp> <csignal> <cstdarg> <cstddef> ·
<cstdio> <cstdlib> <cstring> <ctime> <cwchar> <cwctype>
The C-name headers include the "name.h" header files that are part of the C run-
time library and put the contents into the std namespace.

VERSION2
When VERSION2 is specified, the Standard C++ Library from Rogue Wave Software is
available. This library includes data structure and algorithm classes, plus string and
numeric limits, complex classes, and allocators.
The VERSION2 C++ Library includes:
• A large set of data structures and algorithms formerly known as the Standard
Template Library (STL)
• A locale facility
• A templatized string class
• A templatized complex class for representing complex numbers
• A uniform framework for describing the execution environment through the use of a
template class named numeric_limits and specializations for each
fundamental data type
• Memory management features
• Language support features
• Exception handling features

VERSION1
VERSION1 of the C++ Library includes the data structures and algorithm libraries and
the string, complex, and numeric_limits classes. VERSION1 does not include
templates or exception handling.

HP C/C++ Programmer’s Guide for NonStop Systems —429301-010


5 -5
Using the Standard C++ Library Installation Notes for VERSION3

VERSION1 is not supported on NonStop NS-series systems. To run a C++ program on


a NonStop NS-series system when it is based on VERSION1 of the C++ Library, you
must migrate it to VERSION3, VERSION2, or CPPNEUTRAL before recompiling it.
Migration from VERSION1 to VERSION2 also requires migrating from use of Tools.h++
6.1 to use of Tools.h++ 7. Migration from VERSION1 to VERSION3 requires migrating
from use of either version of Tools.h++. See Using Tools.h++ on page 6-1 and
Migration Considerations for Version 7 on page 6-3.

Installation Notes for VERSION3


The Standard C++ Library ISO/IEC is delivered on the site update tape (SUT) for a
NonStop system. On the PC, the Standard C++ Library is installed with ETK. ETK
requires manual installation of components. The C/C++ cross-compiler installers,
which are part of the ETK product family installs the standard C/C++ library.
Table 5-2 summarizes where the parts of the VERSION3 Standard C++ Library are
installed in the different available environments (Guardian environment, OSS
environment, and PC running Windows).

Table 5-2. Installation Details for Standard C++ Library ISO/IEC


(VERSION3) (page 1 of 2)
Environment Location of Headers Location of Libraries
Guardian $SYSTEM.SYSTEM $SYSTEM.SYSnn.ZSTLSRL
on NonStop S-series systems,
$SYSTEM.ZDLLnnn.ZCPP3DLL
on NonStop NS-series systems
OSS /usr/include The Guardian namespace:
$SYSTEM.SYSnn.ZSTLSRL
on NonStop S-series systems,
$SYSTEM.ZDLLnnn.ZCPP3DLL
on NonStop NS-series systems
PC running C:\Program Files\Compaq C:\Program Files\Compaq ETK-
Windows and ETK-NSE\rel\include NSE\rel\lib
ETK prior to where rel is the release where rel is the release identifier,
release 3.0 identifier, such as G06.20 such as G06.20
To use DLLs, G06.20 or To use DLLs, G06.20 or subsequent
subsequent and ETK release 1.1 and ETK release 1.1 are required.
are required. To use TNS/E compilers or linkers,
To use TNS/E compilers or ETK release 3 is required.
linkers, ETK release 3 is
required.

HP C/C++ Programmer’s Guide for NonStop Systems —429301-010


5 -6
Using the Standard C++ Library Using Header Files With VERSION3

Table 5-2. Installation Details for Standard C++ Library ISO/IEC


(VERSION3) (page 2 of 2)
Environment Location of Headers Location of Libraries
PC running C:\Program Files\Compaq C:\Program Files\Compaq ETK-
Windows and ETK-NSE\rel\usr\include NSE\rel\usr\lib
ETK release where rel is the release where rel is the release identifier,
3.0 or later identifier, such as H06.02 such as H06.01

Using Header Files With VERSION3


Specify the names of the VERSION3 Standard C++ Library header files as defined in
the standard. On NonStop systems, header files have been renamed in some cases to
implement the three versions of the library, but in all cases you need only to specify the
standard names.
To use a VERSION3 header file, do not include .h (even if the standard name contains
.h).
For example, you can specify:
#include <new>
But you cannot specify:
#include <new.h>
Logic has been built into the header files to redirect your calls to the version of the
library you are using. For example, if you are using VERSION2 and you specify:
#include <exception>
Logic in the header files redirects you to the VERSION2 header file, which is actually
named EXCEPTION2 (OSS and Windows) or EXCEPTI2 (Guardian). You can see
these alternate header file names in your program listing, but your include command
should specify only the standard name, such as exception in this example.

Installation Notes for VERSION2


The Standard C++ Library is delivered on the site update tape (SUT) for a NonStop
system. On the PC, the Standard C++ Library is installed with ETK. ETK requires
manual installation of components. The C/C++ cross-compiler installers, which are part
of the ETK product family installs the standard C/C++ library.
Table 5-3 on page 5-8 summarizes where the parts of the VERSION2 Standard C++
Library are installed in the different environments (Guardian environment, OSS
environment, and PC running Windows).

HP C/C++ Programmer’s Guide for NonStop Systems —429301-010


5 -7
Using the Standard C++ Library Examples of VERSION2 Headers

Table 5-3. Installation Details for Rogue Wave Standard C++ Library (VERSION2)
Environment Location of Headers Location of Libraries
Guardian $SYSTEM.SYSTEM TNS/R code:
$SYSTEM.SYSnn.ZRWSLSRL
TNS/E code:
$SYSTEM.ZDLLnnn.ZRWSLDLL
OSS /usr/include The Guardian namespace:
TNS/R code:
$SYSTEM.SYSnn.ZRWSLSRL
TNS/E code:
$SYSTEM.ZDLLnnn.ZRWSLDLL
PC running C:\tdmxdev\rel\include C:\tdmxdev\rel\lib
Windows where rel is the release where rel is the release identifier,
identifier, such as d45 such as d45

Several Standard C++ Library header files have been renamed in the VERSION2
implementation (the Guardian names, inside parentheses, are derived from the first
seven letters plus the last letter of the header file name):
Documented Name Name in VERSION2 Standard C++ Library
exception (EXCEPTIN) rwexcept (RWEXCEPT)
new (NEW) rwnew (RWNEW)
stdexcept (STDEXCET) rwstdex (RWSTDEX)
This renaming avoids conflicts between the C++ run-time header files and the Rogue
Wave Standard C++ Library header files.
If you are using the Rogue Wave Standard C++ Library (VERSION2), you should
specify the header files listed here that begin with RW (that is, RWEXCEPT instead of
EXCEPTION, RWNEW instead of NEW, and RWSTDEX instead of STDEXCEPT).

Examples of VERSION2 Headers


Note. Regardless of the version of the library you are using, the standard header files in the
G06.23 or subsequent RVU automatically redirect calls to the appropriate header file.

1. Specifying the header-file name new includes new.h from the C++ run-time library
in the HP implementation (not the header new in the Standard C++ Library).
#include <new>
//includes header "new,h" from C++ Run-time Library V2
(T0179)

HP C/C++ Programmer’s Guide for NonStop Systems —429301-010


5 -8
Using the Standard C++ Library VERSION2 Standard C++ Library Example Files

2. Specifying the header-file name rwnew includes both new.h and the header file
rwnew from the Standard C++ Library (as renamed for the HP implementation).
#include <rwnew>
//includes standard header "new.h” in addition to “new"
(renamed rwnew) from //Standard C++ Lib (T5895)
3. Specifying the header-file name stdexcept includes stdexcept in the C++ run-
time library in the HP NonStop implementation (not the header file stdexcept,
renamed rwstdex, in the Standard C++ Library).
#include <stdexcept>
//includes header "stdexcept" from C++ RTL V2 (T0179)
4. Specifying the header-file name rwstdex includes the header file stdexcept
from the Standard C++ Library (as renamed for the HP implementation).
#include <rwstdex>
//includes header "stdexcept" from Standard C++ Lib V2
(T5895)

VERSION2 Standard C++ Library Example Files


Example files provided with the VERSION2 Standard C++ Library are located in
$SYSTEM.ZLIBCPL on the NonStop system.

Table 5-4. VERSION2 Standard C++ Library Example Files (page 1 of 4)


Example File Description of Contents
MAKEEXAM MAKE file for the examples. It is an OBEY command file.
CPLUS Macro used by MAKEEXAM to build each test. You need to
modify this file to reflect your own environment.
LINKIT Contains instructions to nld for linking each test. This file is
used by CPLUS. You need to modify this file to reflect your
own environment.
ACCUMC Manual Example Source File
ADJDIFFC Manual Example Source File
ADVANCEC Manual Example Source File
AUTOPTRC Manual Example Source File
BINDERSC Manual Example Source File
BITTESTC Manual Example Source File
BSEARCHC Manual Example Source File
COMTESTC Manual Example Source File
COPYEXC Manual Example Source File
COUNTC Manual Example Source File
DEQUEC Manual Example Source File
DISTANCC Manual Example Source File

HP C/C++ Programmer’s Guide for NonStop Systems —429301-010


5 -9
Using the Standard C++ Library VERSION2 Standard C++ Library Example Files

Table 5-4. VERSION2 Standard C++ Library Example Files (page 2 of 4)


Example File Description of Contents
EQLRANGC Manual Example Source File
EQUALC Manual Example Source File
EXCEPTC Manual Example Source File
FILLC Manual Example Source File
FINDC Manual Example Source File
FINDENDC Manual Example Source File
FINDFOC Manual Example Source File
FOREACHC Manual Example Source File
FUNCTOBC Manual Example Source File
GENERATC Manual Example Source File
HEAPOPSC Manual Example Source File
INCLUDEC Manual Example Source File
INRPRODC Manual Example Source File
INSITRC Manual Example Source File
IOITERC Manual Example Source File
LEXCOMPC Manual Example Source File
LIMTESTC Manual Example Source File
LISTC Manual Example Source File
MAPC Manual Example Source File
MAXC Manual Example Source File
MAXELEMC Manual Example Source File
MERGEC Manual Example Source File
MISMATCC Manual Example Source File
MULTIMAC Manual Example Source File
MULTISEC Manual Example Source File
NEGATORC Manual Example Source File
NTHELEMC Manual Example Source File
PQUEUEC Manual Example Source File
PARTSORC Manual Example Source File
PARTSUMC Manual Example Source File
PERMUTEC Manual Example Source File
PNT2FNCC Manual Example Source File
PRTITIOC Manual Example Source File
QUEUEC Manual Example Source File

HP C/C++ Programmer’s Guide for NonStop Systems —429301-010


5-10
Using the Standard C++ Library VERSION2 Standard C++ Library Example Files

Table 5-4. VERSION2 Standard C++ Library Example Files (page 3 of 4)


Example File Description of Contents
REMOVEC Manual Example Source File
REPLACEC Manual Example Source File
REVITRC Manual Example Source File
REVERSEC Manual Example Source File
RNDSHUFC Manual Example Source File
ROTATEC Manual Example Source File
SEARCHC Manual Example Source File
SETDIFFC Manual Example Source File
SETINTRC Manual Example Source File
SETSDIC Manual Example Source File
SETUNINC Manual Example Source File
SETEXC Manual Example Source File
SORTC Manual Example Source File
STACKC Manual Example Source File
STRTESTC Manual Example Source File
SWAPC Manual Example Source File
TRNSFORC Manual Example Source File
ULBOUNDC Manual Example Source File
UNIQUEC Manual Example Source File
VECTORC Manual Example Source File
ALG1C Tutorial Example Source File
ALG2C Tutorial Example Source File
ALG3C Tutorial Example Source File
ALG4C Tutorial Example Source File
ALG5C Tutorial Example Source File
ALG6C Tutorial Example Source File
ALG7C Tutorial Example Source File
AUTTESTC Tutorial Example Source File
CALCC Tutorial Example Source File
COMPLXC Tutorial Example Source File
CONCORDC Tutorial Example Source File
EXCEPTNC Tutorial Example Source File
ICECREAC Tutorial Example Source File
RADIXC Tutorial Example Source File

HP C/C++ Programmer’s Guide for NonStop Systems —429301-010


5-11
Using the Standard C++ Library Compiling and Linking in the OSS Environment

Table 5-4. VERSION2 Standard C++ Library Example Files (page 4 of 4)


Example File Description of Contents
SIEVEC Tutorial Example Source File
SPELLC Tutorial Example Source File
TELEC Tutorial Example Source File
WIDWORKC Tutorial Example Source File

Compiling and Linking in the OSS


Environment
In addition to the C++ compiler pragmas recognized as command-line flags as
described in Section 13, Compiler Pragmas, the OSS c89 command has a
-Wcplusplus flag that affects both compilation and linking. This flag:
• Defines the __CPLUSPLUS feature-test macro to modify C header files for C++.
• Causes all specified files with names suffixed by .c to be compiled as C++ files.
If a linker is also involved or in other words if -c flag is not used, using the
-Wcplusplus flag causes the standard C++ libraries to be linked.
If the -Wcplusplus flag is not specified and none of the files operated upon by c89
has a suffix of .C, .cpp, .cc, or .cxx, c89 compiles the source files only as
C files; if the -c flag is also omitted, c89 only links the C standard library.

Pragmas for the Standard C++ Library


You need to use the MAPINCLUDE and CPATHEQ pragmas to map UNIX or OSS
pathnames to Guardian file names. HP provides a CPATHEQ file for this purpose; the
file is named SLMAP for the Standard C++ Library. Like any CPATHEQ file, the SLMAP
file maps OSS directory and file names to the Guardian namespace
($volume.subvolume). Similarly, there is a TLHMAP file for mapping names in
Tools.h++ version 7.
The contents of a CPATHEQ file such as the SLMAP file:
#ifndef __SLMAP
#define __SLMAP
#pragma mapinclude "rw/math.h" = "mathh"
#pragma mapinclude "rw/random.h" = "randomh"
#pragma mapinclude "rw/stddefs.h" = "stddefsh"
#pragma mapinclude "rw/stdgen.h" = "stdgenh"
#pragma mapinclude file "algorithm.cc" = "algoricc"
#pragma mapinclude file "bitset.cc" = "bitsetcc"
#pragma mapinclude file "complex.cc" = "complecc"
#pragma mapinclude file "deque.cc" = "dequecc"
#pragma mapinclude file "iterator.cc" = "iteratcc"
#pragma mapinclude file "list.cc" = "listcc"
#pragma mapinclude file "string.cc" = "stringcc"
HP C/C++ Programmer’s Guide for NonStop Systems —429301-010
5-12
Using the Standard C++ Library Using the Neutral C++ Dialect

#pragma mapinclude file "tree.cc" = "treecc"


#pragma mapinclude file "vector.cc" = "vectorcc"
#pragma mapinclude file "sys/types.h" = "systypeh"
#pragma mapinclude file "sys/stat.h" = "sysstath"
#pragma mapinclude file "hash_map" = "hashmap"
#pragma mapinclude file "hash_set" = "hashset"
#endif /* __SLMAP */
Note that this SLMAP file can be used with both VERSION2 and VERSION3.
To use the SLMAP file, enter a CPATHEQ pragma specifying the location of the
SLMAP file. For example:
#pragma cpatheq "$system.system.slmap"
For more details, including examples, about using the MAPINCLUDE and CPATHEQ
pragmas with the Rogue Wave Software products (Tools.h++ and the Standard C++
Library), see Pragmas for Tools.h++ on page 6-6. Also see the pragmas CPATHEQ on
page 13-15 and MAPINCLUDE on page 13-60.

Using the Neutral C++ Dialect


A C++ dialect called the neutral C++ dialect, is defined for the TNS/E native
environment. This dialect, called CPPNEUTRAL, consists of library components that are
common to both VERSION2 and VERSION3 of the Standard C++ Library.
The neutral C++ dialect is used on NonStop NS-series systems by system and
middleware libraries so that C++ programs using either the VERSION2 or VERSION3
Standard C++ Library can use the system and middleware libraries. You can create
your own DLL using the neutral C++ dialect so that your DLL can be similarly used by
either a VERSION2 or VERSION3 C++ program.
Two pragmas support the neutral C++ dialect:
• NEUTRAL
• BUILD_NEUTRAL_LIBRARY.
The NEUTRAL pragma is only allowed in C++ standard headers. This pragma marks a
class definition as being sharable between VERSION2 and VERSION3 of the Standard
C++ Library. If a class definition that is not marked as such is used within a user-
declared type or function that is marked by either the export$ or import$ specifier,
the compiler can be set to issue an error message that indicates a version-dependent
interface is used in a DLL.
The BUILD_NEUTRAL_LIBRARY pragma enables you to create a DLL that uses the
neutral dialect. This pragma can only be used when the VERSION2 or VERSION3 C++
pragma is used. The C++ compiler CPPCOMP generates an error if
BUILD_NEUTRAL_LIBRARY is specified and the program references an object not
marked as NEUTRAL in the corresponding VERSION2 or VERSION3 headers.

HP C/C++ Programmer’s Guide for NonStop Systems —429301-010


5-13
Using the Standard C++ Library Using the Neutral C++ Dialect

The BUILD_NEUTRAL_LIBRARY pragma can also be specified as a flag on the c89


command line as
-Wbuild_neutral_library.
An object is neutral when the library and the application using it conform with these
rules:
• The interface that the library provides uses only C linkage, or
• The interface that the library provides uses C++ linkage and all the parameters in
these interfaces are marked as neutral or are strictly user-defined class types.
• Only these C++ standard library interfaces are shared directly or indirectly between
the library and the user program:
° global new operators
° global delete operators
° stdin, stdout, and stderr
° errno
° class std::exception
° class std::bad_alloc
For example:
To create and link a library that uses the neutral C++ dialect and can be used by either
a VERSION2 or VERSION3 program, enter:
CPPCOMP / IN ZCPPCDLL, OUT $S.#LIST / mydll; SHARED, &
VERSION3, BUILD_NEUTRAL_LIBRARY
where ZCPPCDLL contains only interfaces common to both a VERSION2 and
VERSION3 program; this is the low-level Standard C++ Library. The dynamic-link
library mydll has its CPPNEUTRAL flag set for linker or loader checking.

HP C/C++ Programmer’s Guide for NonStop Systems —429301-010


5-14

You might also like