To successfully compile the code with either compiler, use one of the two alternatives shown below:

void f(const int &); // Use a constant reference. int main () {

f(3); return 0;

}

Or

void f(int &); int i;

int main () { i=3;

f(i);// Use an lvalue for reference initialization. return 0;

}

Digraph White Space Separators

HP C++ does not support alternative tokens (digraphs). In HP aC++, digraphs are supported and legal C++ syntax can be considered an error because of digraph substitution. Insert a blank between two characters of the digraph.

Example:

C<::A> a;

The characters <: are one of the alternative tokens (digraphs) for which HP aC++ performs a

substitution. In this case, <: becomes [. The statement to be compiled becomes C[:A a;, which produces many compilation errors.

To successfully compile this program with either compiler, insert a blank between < and :.

Example:

C< ::A> a;

Migration Considerations when Using Templates

In HP aC++, templates are processed differently than in HP C++ (cfront). HP aC++ does not have a repository. All instantiations are placed in an object (.o) file (with additional information in a

.Ia file if you specify the +inst_auto command-line option). You cannot modify these files as was possible with the files in a repository.

See Chapter 5: “Using HP aC++ Templates” (page 132) for more information.

To begin migrating code containing templates to HP aC++, try to compile and link using the default compile-time instantiation. If this fails with compilation errors, you can compile using one of the following:

The +inst_all option to view all compile-time errors, including template instantiation errors. This may generate errors that will not occur in your program, because the draft standard allows template parameters that cannot instantiate all members. The +inst_all option forces instantiation of such members.

The +inst_directed option to mask compile-time template instantiation errors.

To reset after all translation units compile successfully:

1.Remove any .o and .I files. Using a clobber makefile target to remove .I files is similar to removing the ptrepository directory in cfront.

2.Recompile and link using compile-time instantiation.

Verbose Template Processing Information

Use the +inst v option to replace the cfront -ptvoption tp process verbose template information.

Migration Considerations when Using Templates 219

Page 219
Image 219
HP C/aC++ for PA-RISC Software Migration Considerations when Using Templates, Verbose Template Processing Information