  | 
   
HP C++
HP C++ Class Library Reference Manual
 
 
  
Chapter 1 Overview
The C++ Class Library is a set of headers and other files implementing a 
collection of basic C++ classes. In the library, these classes are 
arranged in functionally related groups called 
packages.
 
The C++ Class Library makes use of other run-time libraries.
 
 
  Note 
Identifiers beginning with
cxxl
 or
CXXL
 are reserved for the C++ Class Library and should not be used by 
 customer programs except as specified in this manual.
 
 
Error message examples in this manual are displayed without their 
OpenVMS facility, error severity, or message identification code 
prefixes. You can achieve this result by entering the following DCL 
command:
 
  
    
       
      
$ set message/nofac/nosev/noid 
 
 |   
     | 
   
 
1.1 Thread Safe Programming
Developers of multithreaded applications should note the following:
 
  - Internal class library data is thread safe; multiple threads can 
  access the C++ Class Library simultaneously without compromising the 
  integrity of the internal data.
  
 - The predefined stream objects,
cerr
,
cin
,
clog
, and
cout
 are thread safe. However, you need to provide synchronization around 
 sequences of operations on these objects. For more information on 
 synchronizing access to the predefined stream objects, see Chapter 4.
  
 - User-defined objects are not thread safe; users must provide 
  synchronization for such objects if they are shared between threads. 
  For more information on synchronizing access to user-defined objects, 
  see Chapter 6.
  
 - The
ios
 class member function
sync_with_stdio()
 is not thread safe; if your application calls this function, the call 
 must come before any threads use the predefined stream objects:
cerr
,
cin
,
clog
, or
cout
.
  
 - Generation of error messages within the vector package is not 
  thread safe; the package uses static data members to handle the current 
  error message and there is no synchronization between threads. HP 
  recommends that you define a single Mutex object to synchronize all use 
  of the vector package.
  
 - The task package is not thread safe; only one task can execute at a 
  time.
  
1.2 Using RMS Attributes with iostreams
The Class Library class
fstream
 constructors amd
open()
 member function do not support different RMS attributes, for example, 
 creating a stream-lf file.
 
To work around this restriction, use the C library
creat()
 or
open()
 call, which returns a file descriptor, and then use the
fstream
constructor, which accepts a file descriptor as its argument. For 
example:
 
 
  
    
       
      
 
 
#include <fstream.hxx> 
 
int main() 
{ 
  int fp; 
 
  // use either creat or open 
  //if ( !(fp= creat("output_file.test", 0, "rfm=stmlf")) ) 
 
  if ( !(fp= open("output_file.test", O_WRONLY | O_CREAT | O_TRUNC , 0, 
"rfm=stmlf")) ) 
    perror("open"); 
 
  ofstream output_file(fp); // use special constructor which takes 
                            // a file descriptor as argument 
  // ... 
} 
 
 |   
1.3 Class Library Restrictions
The following are restrictions in the C++ Class Library:
 
  - No Class Library support for 128-bit long doubles 
 The Class 
  Library does not include support for 128-bit long doubles.
   -  Conflict with redefinition of
clear()
    
 If your program includes both
<curses.h>
 and
<iostream.hxx>
, HP C++ might fail to compile your program because
clear()
 is defined by both header files. In
<curses.h>
,
clear()
 is defined as a macro whereas in
<iostream.hxx>
clear()
 is defined as a member function.  Workarounds:  If your program 
 does not use either
clear()
 or uses the <curses.h>
clear()
, include the
<iostream.hxx>
 header first, followed by
<curses.h>
.  If your program uses the
ios::clear()
 function, undefine the
clear()
 macro directly after the
#include <curses.h>
 statement.
  
  
 |