H-Series Application Migration Guide (H06.03+)

H-Series Application Migration Guide429855-006
5-1
5
Native C and C++ Migration Tasks
This section describes how to migrate programs written in the G-series TNS/R native
HP C and C++ for NonStop systems languages to an H-series system. Topics in this
section are:
Using the TNS/E Native C and C++ Compilers.
Possible Source Code Changes on page 5-2.
Changed Pragmas and Flags on page 5-4
Native C and C++ Run-Time Library and Tools.h++ Migration Issues on page 5-7.
Undefined Behavior in C and C++ Programs on page 5-11
New H-Series C and C++ Features on page 5-11.
Using the TNS/E Native C and C++ Compilers
Both the TNS/R and TNS/E native C and C++ compilers conform to the ISO/ANSI C
language standard (ISO/IEC 9899:1990 for C, ISO/IEC 14882:1998 for C++). Source
code that compiles without warnings or errors with the TNS/R native C or C++ compiler
will likely compile without warnings or errors using the TNS/E native C or C++ compiler.
The text and number of diagnostic messages produced by the TNS/R and TNS/E
native compilers are nearly identical.
Program logic or behavior that depends on the underlying machine architecture or
uses undocumented features (mainly privileged features) might require changes to
compile and run correctly using the TNS/E native compilers.
The C and C++ compilers can be run in the OSS or Guardian environment. TNS/E
native C and C++ also provide a PC-based cross-compiler that can be run either at the
Windows command prompt or through the Enterprise Toolkit - NonStop Edition (ETK).
In the Guardian environment. The CCOMP command runs the TNS/E native C compiler
and the CPPCOMP command runs the TNS/E native C++ compiler. In the OSS and PC
environments, the c89 command runs the native C and C++ compilers.
The H-series version of the c89 command for the PC and the OSS environment
provides a new option to specify the target platform for the compilation: specify
-Wtarget=TNS/R to generate RISC code or -Wtarget=TNS/E to generate Itanium code.
The default for the PC is -Wtarget=TNS/R. The default for OSS is the same as the host
platform. The G-series c89 command does not support this option and can compile
only for TNS/R execution. Note that TNS/R code cannot be executed on a TNS/E
platform, and TNS/E code cannot be executed on a TNS/R platform.
All code generated by the TNS/E native compilers is position-independent code (PIC).
PIC is code that need not be modified to run at different virtual addresses. It is used to
create dynamic-link libraries (DLLs). TNS/E native compilers do not provide an option
to generate non-PIC, and do not support SRLs.