2.3.8. C++ Language configuration and object generation

These options enable you to control various elements of the C++ compilation:

--exceptions --no_exceptions

Enables or disables C++ exception handling (see C++ exception handling). The default behavior is --no_exceptions.

Compiling with exceptions enabled causes the compiler to emit unwinding tables to support exception propagation at runtime. Also in C++ it enables the use of the throw and try/catch function exception specifications.

Note

When --no_exceptions is in force, throw and try/catch are not permitted in source code. However, function exception specifications are still parsed, but most of their meaning is ignored.

--exceptions_unwind --no_exceptions_unwind

Enables or disables function unwinding for exceptions-aware C++ code (see Function unwinding at runtime). The default behavior is --exceptions_unwind.

You must also specify --exceptions if you want to use these options.

--export_all_vtbl

Enables you to control how dynamic symbols are exported. Use this option to export all virtual table (vtable) functions and Runtime Type Information (RTTI) for classes with a key function. A key function is the first virtual function of a classs, in declaration order, that is not inline, and is not pure virtual.

You can disable export for specific classes by using __declspec(notshared). For example:


struct __declspec(notshared) X { virtual int f(); }; 
                                   // Do not export this
int X::f() {return 1;}
struct Y : X { virtual int g(); }; // Do export this
int Y::g() {return 1;}
--export_defs_implicitly

Enables you to control how dynamic symbols are exported. Use this option to export definitions where the prototype was marked dllimport.

--dllexport_all

Enables you to control symbol visibility when building DLLs. Use this option to mark all extern definitions as __declspec(dllexport).

--no_hide_all

Enables you to control symbol visibility when building SVr4 shared objects. Use this option to mark all extern definitions as __declspec(dllexport), and to import all undefined references.

--force_new_nothrow

The C++ Standard states that only a no throw operator new is permitted to return NULL on failure. Any other operator new is never permitted to return NULL and the default operator new throws an exception.

If you use --force_new_nothrow then the compiler treats expressions


new T(...args...)

that use the global ::operator new or ::operator new[] as if they are


new (std::nothrow) T(...args...)

--force_new_nothrow also causes any class-specific operator new or any overloaded global operator new to be treated as throw(), for example:


struct S {
    void* operator new(std::size_t);
    void* operator new[](std::size_t);
};
void *operator new(std::size_t, int);

This is treated as:


struct S {
    void* operator new(std::size_t) throw();
    void* operator new[](std::size_t) throw();
};
void *operator new(std::size_t, int) throw();

For more details on operator new, see Using the ::operator new function.

The default is to follow the C++ Standard.

--implicit_include --no_implicit_include

Enable or disable implicit inclusion of source files as a method of finding definitions of template entities to be instantiated. See Template instantiation. The default behavior is --implicit_include.

--pending_instantiations=n

Specifies the maximum number of concurrent instantiations of a given template that can be in the process of being instantiated. This is used to detect runaway recursive instantiations. If n is zero, there is no limit. The default value is 64.

--nonstd_qualifier_deduction --no_nonstd_qualifier_deduction

Controls whether or not nonstandard template argument deduction is to be performed in the qualifier portion of a qualified name. With this feature enabled, a template argument for the template parameter T can be deduced in contexts like A<T>::B or T::B. The standard deduction mechanism treats these as non-deduced contexts that use the values of template parameters that were either explicitly specified or deduced elsewhere. The default is --no_nonstd_qualifier_deduction.

--rtti --no_rtti

Enables or disables support for RTTI features dynamic_cast and typeid. The default behavior is --rtti.

--using_std --no_using_std

Enables or disables implicit use of the std namespace when standard header files are included. See Namespaces for more details. The default behavior is --no_using_std.

--old_specializations --no_old_specializations

Enables or disables the acceptance of old-style template specializations. That is, specializations that do not use the template<> syntax. The default behavior is --no_old_specializations.

--guiding_decls --no_guiding_decls

Enables or disables the recognition of guiding declarations of template functions. A guiding declaration is a function declaration that matches an instance of a function template but has no explicit definition (because its definition derives from the function template), for example:


template <class T> void f(T) { ... }
void f(int);

When regarded as a guiding declaration, f(int) is an instance of the template. Otherwise, it is an independent function so you must supply a definition.

If --no_guiding_decls is combined with --old_specializations, a specialization of a non-member template function is not recognized. It is treated as a definition of an independent function.

The default behavior is --no_guiding_decls.

--implicit_typename --no_implicit_typename

Enables or disables implicit determination, from context, whether a template parameter dependent name is a type or nontype. The default behavior is --no_implicit_typename.

Note

The --implicit_typename option has no effect unless you also specifiy --no_parse_templates.

See Template instantiation, for more details.

--parse_templates --no_parse_templates

Enables or disables the parsing of non-class templates in their generic form, that is, even if they are not actually instantiated. If dependent name processing is enabled, then parsing is done by default.

See Template instantiation, for more details.

--dep_name --no_dep_name

Enables or disables dependent name processing. That is, the separate lookup of names in templates at the time the template is parsed, and at the time it is instantiated.

The default behavior is --dep_name.

Note

--dep_name cannot be combined with --no_parse_templates. Attempting to use these options together, generates the following error:


#1054: option "dep_name" cannot be used with "no_parse_templates"

See Template instantiation, for more details.

--friend_injection --no_friend_injection

In C++, these options control whether or not the name of a class or function that is declared only in friend declarations is visible when using the normal lookup mechanisms.

When friend names are injected, they are visible to these lookups. When friend names are not injected (as required by the standard), function names are visible only when using argument-dependent lookup, and class names are never visible.

For details on friend declarations, see friend.

Copyright © 2005 ARM Limited. All rights reserved.ARM DUI 0282B
Non-Confidential