Compiling the following code with HP C++ causes a warning. Compiling with HP aC++ generates an error stating that overload is used as a type, but has not been defined as a type.

int f(int i);

overload int f(float f); // Remove the word overload. int main () {

return 1;

}

Dangling Comma in enum

In HP C++, a comma following the last element in an enum list is ignored. In HP aC++, a comma following the last element in an enum list generates an error. To avoid this error, remove the comma after the last element.

Example:

HP C++ accepts the following code. HP aC++ generates an error stating that the comma (,) is unexpected.

enum Colors { red,

 

orange,

 

yellow,

 

green,

 

blue,

 

indigo,

 

violet,

// This comma is illegal.

};

 

Static Member Definition Required

In HP C++, you can declare a static member and not define it. However, in HP aC++, you cannot do so. You must define the declared static data member.

Example:

Compiling and linking the following code on HP C++ gives no warning nor error. Compiling the code on HP aC++ gives neither a warning nor an error. Linking the resulting object file generates a linker (ld) error that states that there are unsatisfied symbols.

class A { public:

static int staticmember;

};

// int A::staticmember=0; // This would fix the problem. int main ()

{

A::staticmember=1;

}

Declaring friend Classes

In HP C++, you can declare friend classes without the class keyword. In HP aC++, declaring friend classes without the class keyword generates an error. To change this, add the class keyword to all friend class declarations.

Example:

Compiling the following code on HP C++ does not generate a warning or an error. Compiling the code on HP aC++ generates an error stating that the friend declaration for B is not in the right form for either a function or a class.

class foo{

public:

 

friend bar;

// Need to say: friend class B

};

 

int main (){

 

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

Page 214
Image 214
HP C/aC++ for PA-RISC Software manual Dangling Comma in enum, Static Member Definition Required, Declaring friend Classes