12 Migrating from HP C++ (cfront) to HP aC++

This chapter discusses differences in syntax and functionality that you need to consider when migrating from HP C++ (cfront) to HP aC++.

It discusses the following topics:

“General Guidelines for Migration” (page 198)

“Command-Line Differences” (page 199)

“Migration Considerations when Debugging” (page 202)

“Migration Considerations when Using Exception Handling” (page 202)

“Migration Considerations when Using Libraries” (page 206)

“Migration Considerations Related to Standardization” (page 209)

“Migration Considerations when Using Templates” (page 219)

NOTE: The HP C++ and HP aC++ compilers execute independently and can be installed on a single system. HP C++ is located at /opt/CC. HP aC++ is located at /opt/aCC.

General Guidelines for Migration

Because of incompatibilities in areas such as name mangling, libraries, and object layout, all of your C++ code for an application or library must be compiled and linked with either HP C++ (cfront) or with HP aC++. You cannot mix object files compiled with HP C++ (cfront) with those compiled with HP aC++.

This section discusses the general guidelines when migrating from HP C++ (cfront) to HP aC++.

Getting Started with Migration

Complete the following procedure to migrate your code from HP C++ (cfront) to HP aC++:

1.Compile your code with the HP C++ (cfront) compiler using the +p option. This option requests the compiler to treat anachronistic constructs as errors. Fix the anachronisms. For example:

CC +p cfrontfile.C

2.In your Makefiles:

Change CC to aCC.

Set the path to/opt/aCC/bin.

Review command-line options and change when necessary.

3.Compile and fix syntax errors.

Note that cfront-generated object code and libraries are not compatible with those produced by aCC.

If your program uses operator new, allow for memory allocation exceptions that may occur. Modify your cfront code to handle memory allocation failures to avoid a program abort.

4.Make library changes. Begin migration to the Standard C++ Library and Tools.h++ Library.

5.Make template changes.

If a program or library uses templates, consider source code changes that may be required to direct template instantiation.

Use the +inst_directed option with the initial compilation to defer consideration of compile-time errors due to template instantiation.

198 Migrating from HP C++ (cfront) to HP aC++