C++ Migration Guide

Compatibility Mode

The compiler options for compatibility mode are (both versions mean the same thing):


-compat
-compat=4

For example:
CC -compat -O myfile.cc mylib.a -o myprog

There are some minor differences between using the C++ 4 compiler and the C++ 5.0 compiler in compatibility mode, as described in the following sections.

Keywords in Compatibility Mode

By default, some of the new C++ keywords are recognized as keywords in compatibility mode, but you can turn off most of these keywords with compiler options, as shown in the following table. Changing the source code to avoid the keywords is preferable to using the compiler options.

Table 2-1 Keywords in Compatibility Mode

Keyword 

Compiler option to disable 

explicit

-features=no%explicit

export

-features=no%export

mutable

-features=no%mutable

typename

cannot disable

Keyword typename cannot be disabled. The additional new C++ keywords, described in Table 3-1, are disabled by default in compatibility mode.

Language Semantics

The 5.0 compiler does a better job of enforcing some C++ language rules. It is also less permissive about anachronisms.

If you compile with C++ 4 and enable anachronism warnings, you might discover code that has always been invalid, but that much older C++ compilers accepted anyway. It was always explicit policy (that is, stated in the manuals) that the anachronisms would cease to be supported in future compiler releases. The anachronisms consist mainly of violating access (private, protected) rules, violating type-matching rules, and using compiler-generated temporary variables as the target of reference parameters.

The rules that previously were not enforced are as follows: