Chapter 3. MIPSpro C++ and the C++ Standard

The MIPSpro C++ compiler implements the C++ language as defined in the C++ International Standard with the exception of the features listed in “Unimplemented C++ Standard Language Features”.

This chapter discusses the following topics:

The compiler provides special compatability modes for compiling older, outmoded programs. See Appendix B, “Cfront Compatability”, and Appendix C, “Anachronisms Accepted”, for information.

Unimplemented C++ Standard Language Features

The MIPSpro C++ compiler implements the full C++ language as described in the ISO/IEC 14882: Programming Language -- C++ document (referred to as “The Standard” in this text) with the following exceptions:

  • extern inline functions are not supported. Inline functions always have internal linkage. See section 3.5 of the Standard.

  • The export keyword is not supported. See section 2.11 of the Standard.

  • By default, the new template name resolution rules are not supported. See section 14.6 of the Standard. To use the new rules, you can use the -LANG:do-dependent-name-processing option.

    Standard header files, like iostream, have not been corrected to conform with these rules and will not compile with this option.

  • The stack is not unwound on a violated exception specification. See section 15.5.2 of the Standard.

  • Placement delete is not implemented (Section 5.3.4).

Feature Control

A number of options in the LANG group can be used to control the set of C++ features that are supported. These options can be used, for example, to compile code that does not conform with the Standard in one way or another. It may not always be possible, however, to link together object files, some of which have been compiled with a feature enabled and others with it disabled.

  • -LANG:bool=off: removes the bool keyword. Use this, for example, to compile code in which bool is a typedef for some integral type.

  • -LANG:exceptions=off: disables exception handling. try, throw, catch , for example, will not be recognized as keywords. You may want to use this option to save space; some code may run slightly faster with exceptions disabled.

  • -LANG:wchar_t=off: removes the wchar_t keyword. Use this, for example, to compile code in which wchar_t is a typedef for some integral type.

  • -LANG:namespaces=off: removes the namespace keyword.

  • -LANG:ansi-for-init-scope=off: affects the scope of the loop variable in the construct:

    for (int i = 0;...)

    The Standard specifies that the scope of the loop variable extends only to the end of the for statement. The old behavior made the scope extend to the end of the enclosing block. Use this option to revert to that behavior. It is safe to mix object files compiled with and without this option.

  • -LANG:std=off: disables a number of requirements of the Standard, mostly rather minor and technical. The most important of these are the following:

    • the typename keyword is not always required.

    • the template<> syntax is not required for template specializations.

    • the scope of for loop variables extends to the enclosing block, just as if -LANG:ansi-for-init-scope=off had been specified.

    • there are slight differences in overload resolution, with the effect that some function calls that would be ambiguous under the Standard are resolved by "late tiebreaker" rules.

    • string literals have type char[] instead of const char[].

  • -LANG:libc_in_namespace_std=off: This disables the predefined macro _LIBC_IN_NAMESPACE_STD, used for header-file functionality that puts C library functions like printf into namespace std as required by the C++ Standard. Use this option if you use C header files such as stdio.h instead of the C++ versions such as cstdio, for example.

Extensions Accepted

  • The long long and unsigned long long types provide a 64-bit integral type. This is accepted in default mode. The use of long long is flagged with a warning if the -ansiW or -ansiE option is specified.

  • C99-style variable length arrays are supported with the -LANG:vla=on command line option. Not accepted in default mode.

  • The restrict keyword is supported with the -LANG:restrict=on command line option. Not accepted in default mode.

Note that long long is accepted by default; restrict and variable length arrays are accepted only with special command line options. When you use the special options for restrict and variable length arrays, there are no diagnostics for their use even if you specify the -ansiE or -ansiW options. long long is accepted by default and there is a warning if you specify -ansiE or -ansiW, but never an error.