Sun Studio 12 Update 1: C++ User's Guide

A.2.19 –features=a[,a...]

Enables/disables various C++ language features named in a comma-separated list.

A.2.19.1 Values

In both compatibility mode (-compat[=4]) and standard mode (the default mode), a can have the following values.

Table A–6 The -features Values for Compatibility Mode and Standard Mode

Value 

Meaning  

%all

All the -features options that are valid for the specified mode (compatibility mode or standard mode).

[no%]altspell

[Do not] Recognize alternative token spellings (for example, “and” for “&&”). The default is no%altspell in compatibility mode and altspell in standard mode.

[no%]anachronisms

[Do not] Allow anachronistic constructs. When disabled (that is, -features=no%anachronisms), no anachronistic constructs are allowed. The default is anachronisms.

[no%]bool

[Do not] Allow the bool type and literals. When enabled, the macro _BOOL=1. When not enabled, the macro is not defined. The default is no%bool in compatibility mode and bool in standard mode.

[no%]conststrings

[Do not] Put literal strings in read-only memory. The default is no%conststrings in compatibility mode and conststrings in standard mode.

[no%]except

[Do not] Allow C++ exceptions. When C++ exceptions are disabled (that is, -features=no%except), a throw-specification on a function is accepted but ignored; the compiler does not generate exception code. Note that the keywords try, throw, and catch are always reserved. See 8.3 Disabling Exceptions. The default is except.

[no%]export

[Do not] Recognize the keyword export. The default is no%export in compatibility mode and export in standard mode. This feature is not yet implemented, but the export keyword is recognized.

[no%]extensions

[Do not] allow nonstandard code that is commonly accepted by other C++ compilers. See Table 3–17 for an explanation of the invalid code that is accepted by the compiler when you use the -features=extensions option. The default is no%extensions.

[no%]iddollar

[Do not] Allow a $ symbol as a noninitial identifier character. The default is no%iddollar.

[no%]localfor

[Do not] Use new local-scope rules for the for statement. The default is no%localfor in compatibility mode and localfor in standard mode.

[no%]mutable

[Do not] Recognize the keyword mutable. The default is no%mutable in compatibility mode and mutable in standard mode.

[no%]split_init

[Do not] Put initializers for nonlocal static objects into individual functions. When you use -features=no%split_init, the compiler puts all the initializers in one function. Using -features=no%split_init minimizes code size at the possible expense of compile time. The default is split_init.

[no%]transitions

[Do not] allow ARM language constructs that are problematic in standard C++ and that may cause the program to behave differently than expected or that may be rejected by future compilers. When you use -features=no%transitions, the compiler treats these as errors. When you use -features=transitions in standard mode, the compiler issues warnings about these constructs instead of error messages. When you use -features=transitions in compatibility mode (-compat[=4]), the compiler displays the warnings about these constructs only if +w or +w2 is specified. The following constructs are considered to be transition errors: redefining a template after it was used, omitting the typename directive when it is needed in a template definition, and implicitly declaring type int. The set of transition errors may change in a future release. The default is transitions.

%none

Turn off all the features that can be turned off for the specified mode. 

In standard mode (the default mode), a can have the following additional values.

Table A–7 The -features Values for Standard Mode Only

Value 

Meaning  

[no%]strictdestrorder

[Do not] Follow the requirements specified by the C++ standard regarding the order of the destruction of objects with static storage duration. The default is strictdestrorder.

[no%]tmplrefstatic

[Do not] allow function templates to refer to dependent static functions or static function templates. The default is the standard conformant no%tmplrefstatic.

[no%]tmplife

[Do not] Clean up the temporary objects that are created by an expression at the end of the full expression, as defined in the ANSI/ISO C++ Standard. (When -features=no%tmplife is in effect, most temporary objects are cleaned up at the end of their block.) The default is no%tmplife in compat=4 mode and tmplife in standard mode.

In compatibility mode (-compat[=4]), a can have the following additional values.

Table A–8 The -features Values for Compatibility Mode Only

Value 

Meaning  

[no%]arraynew

[Do not] Recognize array forms of operator new and operator delete (for example, operator new [ ] (void*)). When enabled, the macro __ARRAYNEW=1. When not enabled, the macro is not defined. The default is no%arraynew.

[no%]explicit

[Do not] Recognize the keyword explicit. The default is no%explicit.

[no%]namespace

[Do not] Recognize the keywords namespace and using. The default is no%namespace.

The purpose of -features=namespace is to aid in converting code to standard mode. By enabling this option, you get error messages if you use these keywords as identifiers. The keyword recognition options allow you to find uses of the added keywords without having to compile in standard mode.

[no%]rtti

[Do not] Allow runtime type information (RTTI). RTTI must be enabled to use the dynamic_cast<> and typeid operators. For -compat=4 mode, the default is no%rtti. Otherwise, the default is -features=rtti, and the option -features=no%rtti is not allowed.


Note –

The [no%]castop setting is allowed for compatibility with makefiles written for the C++ 4.2 compiler, but has no affect on later compiler versions. The new style casts ( const_cast, dynamic_cast, reinterpret_cast, and static_cast) are always recognized and cannot be disabled.


Defaults

If –features is not specified, the default in compatibility mode (-compat[=4]) is:


–features=%none,anachronisms,except,split_init,transitions

In the default “standard mode”,


-features=%all,no%extensions,no%iddollar,no%tmplrefstatic

is assumed.

Interactions

This option accumulates instead of overrides.

Use of the following in standard mode (the default) is not compatible with the standard libraries and headers:

In compatibility mode (-compat[=4]), the -features=transitions option has no effect unless you specify the +w option or the +w2 option.

Warnings

Be careful when you specify -features=%all or -features=%none. The set of features can change with each compiler release and with each patch. Consequently, you can get unintended behavior.

The behavior of a program might change when you use the -features=tmplife option. Testing whether the program works both with and without the -features=tmplife option is one way to test the program’s portability.

The compiler assumes -features=split_init by default in compat mode (-compt=4). If you use the -features=%none option to turn off other features, you may find it desirable to turn the splitting of initializers into separate functions back on by using -features=%none,split_init instead.

See also

Table 3–17 and the C++ Migration Guide