User's Guide

IOSTREAM Performance Improvement Pragma
The -AA -D_HP_NONSTD_FAST_IOSTREAM Performance Improvement macro can be used to
improve the -AA iostream performance.
Syntax:
#define _HP_NONSTD_FAST_IOSTREAM 1 (or)
aCC options -D_HP_NONSTD_FAST_IOSTREAM
This macro enables the following non-standard features:
Sets std::ios_base::sync_with_stdio(false), which disables the default
synchronization with stdio
Sets std::cin.tie(0). which unties the cin from other streams.
Replaces all occurrences of “std::endl” with “\n.
Enabling this macro can provide noticeable performance improvement if the application uses
iostreams often.
NOTE: Note: Do not enable the HP_NONSTD_FAST_IOSTREAM macro in any of the following
cases:.
If the application assumes a C++ stream to be in sync with a C stream.
If the application depends on stream flushing behavior with endl.
If the user uses "std::cout.unsetf(ios::unitbuf)" to unit buffer the output stream.
Pragma Directive (#pragma) and _Pragma Operator
A #pragma directive is an instruction to the compiler. Use a pragma to control the actions of the
compiler in a particular portion of a program without affecting the program as a whole.
Syntax
pragma-directive ::=
#pragma [token-list]
Description
The #pragma directive is ignored by the preprocessor, and instead is passed on to the HP aC++
compiler. It provides implementation-dependent information to HP aC++. Any pragma that is not
recognized by HP aC++ will generate a warning from the compiler.
The _Pragma operator, supported in non-strict C++98/C++03 mode and in all C++0x modes,
has the effect of expanding the pragma specified in the string (in double-quotes) in just the way a
#pragma directive would. For example:
_Pragma ("pack 1");
struct Packed {
char c;
int i;
};
int main () {
int iPackedSize = sizeof(Packed);
}
See Chapter 3 (page 96) for more information on pragmas.
Example
#pragma OPTIMIZE ON
Overview of the Preprocessor 129