HP aC++/HP C A.06.28 Programmer's Guide Integrity servers (769150-001, March 2014)
Note that conditional compilation may be necessary to accommodate both the user threads and
the kernel threads interfaces, as in the above example. An alternative might be to compose a buffer
with an ostrstream and output with one write. The following example could be used with the
cfront compatiblelibstream:
ostrstream ostr;
ostr << “something” /*...*/ ;
ostr << “ or another” /*...*/ << endl;
cout.write(ostr.str(), ostr.pcount());
ostr.rdbuf()->freeze(0);
Note that the above example works with the new library, though with the deprecated ostrstream.
Or something similar can be done with the Rogue Wave Standard C++ Library 2.2.1 (libstd_v2)
with standard ostringstream, as in the following example:
ostringstream ostr;
ostr << “something” /*...*/ ;
ostr << “ or another” /*...*/ << endl;
cout.write(ostr.str().c_str(), ostr.str().length());
Note that cout.flush may be needed if sharing the file with stdio.
Required Command-line Options
To use the multi-thread safe capabilities of the Standard C++ Library, you need to specify the
following options at both compile and link time. Note that the options differ depending on which
set of libraries you are using.
Rogue Wave Standard C++ Library 2.2.1
For both 32-bit and 64-bit libraries:
• -D_RWSTD_MULTI_THREAD
• -D_REENTRANT
• -lpthread (This option applies only to kernel threads.)
• -mt
Rogue Wave Standard C++ Library 1.2.1 and Tools.h++ 7.0.6
For both 32-bit and 64-bit libraries:
• -D__HPACC_THREAD_SAFE_RB_TREE (Code compiled with this option is binary incompatible
with code that is not compiled with this option. Only HP aC++ version A.01.21 and subsequent
versions incorporate this option.)
• -DRWSTD_MULTI_THREAD
• -DRW_MULTI_THREAD (needed only for the Tools.h++ Library)
• -D_REENTRANT
• -lcma (This option applies only to user threads.)
• -lpthread (This option applies only to kernel threads.)
• -D_THREAD_SAFE (Unlike the other options in this table, this option is not required. You can
use it with the cout, cin, cerr, and clog objects, if you are not using locks.)
• -mt
NOTE: If you do not specify these options as described in both cases, a runtime error will be
generated or multi-thread behavior will be incorrect. If you use +Oopenmp in an application, you
must use -mt on files that are not compiled with +Oopenmp.
164 Exception Handling