A P P E N D I X  A

C++ Compiler Options

This appendix details the command-line options for the C++ compiler. The features described apply to all platforms except as noted; features that are unique to the Solaris OS on SPARC-based systems are identified as SPARC, and the features that are unique to the Solaris OS on x86-based systems are identified as x86.

The following table shows examples of typical option syntax formats.


TABLE A-1 Option Syntax Format Examples

Syntax Format

Example

-option

-E

-optionvalue

-Ipathname

-option=value

-xunroll=4

-option value

-o filename


The typographical conventions that are listed in "Before You Begin" at the front of this manual are used in this section of the manual to describe individual options.

Parentheses, braces, brackets, pipe characters, and ellipses are metacharacters used in the descriptions of the options and are not part of the options themselves.


A.1 How Option Information Is Organized

To help you find information, compiler option descriptions are separated into the following subsections. If the option is one that is replaced by or identical to some other option, see the description of the other option for full details.


TABLE A-2 Option Subsections

Subsection

Contents

Option Definition

A short definition immediately follows each option. (There is no heading for this category.)

Values

If the option has one or more values, this section defines each value.

Defaults

If the option has a primary or secondary default value, it is stated here.

The primary default is the option value in effect if the option is not specified. For example, if -compat is not specified, the default is -compat=5.

The secondary default is the option in effect if the option is specified, but no value is given. For example, if -compat is specified without a value, the default is -compat=4.

Expansions

If the option has a macro expansion, it is shown in this section.

Examples

If an example is needed to illustrate the option, it is given here.

Interactions

If the option interacts with other options, the relationship is discussed here.

Warnings

If there are cautions regarding use of the option, they are noted here, as are actions that might cause unexpected behavior.

See also

This section contains references to further information in other options or documents.

"Replace with" "Same as"

If an option has become obsolete and has been replaced by another option, the replacement option is noted here. Options described this way may not be supported in future releases.

If there are two options with the same general meaning and purpose, the preferred option is referenced here. For example, "Same as -xO" indicates that -xO is the preferred option.



A.2 Option Reference

A.2.1 -386

x86: Same as -xtarget=386. This option is provided for backward compatibility only.

A.2.2 -486

x86: Same as -xtarget=486. This option is provided for backward compatibility only.

A.2.3 -a

Same as -xa.

A.2.4 -Bbinding

Specifies whether a library binding for linking is symbolic, dynamic (shared), or static (nonshared).

You can use the -B option several times on a command line. This option is passed to the linker, ld.



Note - Many system libraries are only available as dynamic libraries in the Solaris 64-bit compilation environment. Therefore, do not use -Bstatic as the last toggle on the command line.



Values

binding must be one of the following:


Value of binding

Meaning

dynamic

Directs the link editor to look for liblib.so (shared) files, and if they are not found, to look for liblib.a (static, nonshared) files. Use this option if you want shared library bindings for linking.

static

Directs the link editor to look only for liblib.a (static, nonshared) files. Use this option if you want nonshared library bindings for linking.

symbolic

Forces symbols to be resolved within a shared library if possible, even when a symbol is already defined elsewhere.

See the ld(1) man page.


(No space is allowed between -B and the binding value.)

Defaults

If -B is not specified, -Bdynamic is assumed.

Interactions

To link the C++ default libraries statically, use the -staticlib option.

The -Bstatic and -Bdynamic options affect the linking of the libraries that are provided by default. To ensure that the default libraries are linked dynamically, the last use of -B should be -Bdynamic.

In a 64-bit environment, many system libraries are available only as shared dynamic libraries. These include libm.so and libc.so (libm.a and libc.a are not provided). As a result, -Bstatic and -dn may cause linking errors in 64-bit Solaris operating systems. Applications must link with the dynamic libraries in these cases.

Examples

The following compiler command links libfoo.a even if libfoo.so exists; all other libraries are linked dynamically:


example% CC a.o -Bstatic -lfoo -Bdynamic

Warnings

Never use -Bsymbolic with programs containing C++ code, use linker map files instead.

With -Bsymbolic, references in different modules can bind to different copies of what is supposed to be one global object.

The exception mechanism relies on comparing addresses. If you have two copies of something, their addresses won't compare equal, and the exception mechanism can fail because the exception mechanism relies on comparing what are supposed to be unique addresses.

If you compile and link in separate steps and are using the -Bbinding option, you must include the option in the link step.

See also

-nolib, -staticlib, ld(1), Section 12.5, Statically Linking Standard Libraries, Linker and Libraries Guide

A.2.5 -c

Compile only; produce object .o files, but suppress linking.

This option directs the CC driver to suppress linking with ld and produce a .o file for each source file. If you specify only one source file on the command line, then you can explicitly name the object file with the -o option.

Examples

If you enter CC -c x.cc, the x.o object file is generated.

If you enter CC -c x.cc -o y.o, the y.o object file is generated.

Warnings

When the compiler produces object code for an input file (.c, .i), the compiler always produces a .o file in the working directory. If you suppress the linking step, the .o files are not removed.

See also

-o filename, -xe

A.2.6 -cg{89|92}

Same as -xcg{89|92}.

A.2.7 -compat[={4|5}]

Sets the major release compatibility mode of the compiler. This option controls the __SUNPRO_CC_COMPAT and __cplusplus macros.

The C++ compiler has two principal modes. The compatibility mode accepts ARM semantics and language defined by the 4.2 compiler. The standard mode accepts constructs according to the ANSI/ISO standard. These two modes are incompatible with each other because the ANSI/ISO standard forces significant, incompatible changes in name mangling, vtable layout, and other ABI details. These two modes are differentiated by the -compat option as shown in the following values.

Values

The -compat option can have the following values.


Value

Meaning

-compat=4

(Compatibility mode) Set language and binary compatibility to that of the 4.0.1, 4.1, and 4.2 compilers. Set the __cplusplus preprocessor macro to 1 and the __SUNPRO_CC_COMPAT preprocessor macro to 4.

-compat=5

(Standard mode) Set language and binary compatibility to ANSI/ISO standard mode. Set the __cplusplus preprocessor macro to 199711L and the __SUNPRO_CC_COMPAT preprocessor macro to 5.


Defaults

If the -compat option is not specified, -compat=5 is assumed.

If only -compat is specified, -compat=4 is assumed.

Interactions

You cannot use the standard libraries in compatibility mode (-compat[=4]).

Use of -compat[=4] with any of the following options is not supported.

Use of -compat=5 with any of the following options is not supported.

Warnings

When building a shared library do not use -Bsymbolic.

See also

C++ Migration Guide

A.2.8 +d

Does not expand C++ inline functions.

Under the C++ language rules, a C++ inline function is a function for which one of the following statements is true.

Under the C++ language rules, the compiler can choose whether actually to inline a call to an inline function. The C++ compiler inlines calls to an inline function unless:

Examples

By default, the compiler may inline the functions f() and memf2() in the following code example. In addition, the class has a default compiler-generated constructor and destructor that the compiler may inline. When you use +d, the compiler will not inline f()and C::mf2(), the constructor, and the destructor.


inline int f() {return 0;} // may be inlined
class C {
  int mf1(); // not inlined unless inline definition comes later
  int mf2() {return 0;} // may be inlined
};

Interactions

This option is automatically turned on when you specify -g, the debugging option.

The -g0 debugging option does not turn on +d.

The +d option has no effect on the automatic inlining that is performed when you use -xO4 or -xO5.

See also

-g0, -g

A.2.9 -D[ ]name[=def]

Defines the macro symbol name to the preprocessor.

Using this option is equivalent to including a #define directive at the beginning of the source. You can use multiple -D options.

Values

The following table shows the predefined macros. You can use these values in such preprocessor conditionals as #ifdef.


TABLE A-3 P redefined Macros

Type

Macro Name

Notes

SPARC and x86

_ _ARRAYNEW

_ _ARRAYNEW is defined if the "array" forms of operators new and delete are enabled. See -features=[no%]arraynew for more information.

 

_ BOOL

_BOOL is defined if type bool is enabled. See -features=[no%]bool for more information.

 

_ _BUILTIN_VA_ARG_INCR

For the _ _builtin_alloca, _ _builtin_va_alist, and _ _builtin_va_arg_incr keywords in varargs.h, stdarg.h, and sys/varargs.h.

 

_ _cplusplus

 

 

_ _DATE_ _

 

 

_ _FILE_ _

 

 

_ _LINE_ _

 

 

_ _STDC_ _

Set to 0 (zero)

 

_ _sun

 

 

sun

See Interactions.

 

_ _SUNPRO_CC=0x580

The value of _ _SUNPRO_CC indicates the release number of the compiler

 

_ _SUNPRO_CC_COMPAT=4 or _ _SUNPRO_CC_COMPAT=5

See Section A.2.7, -compat[={4|5}]

(SPARC)

__SUN_PREFETCH=1

 

 

_ _SVR4

 

 

_ _TIME_ _

 

 

_ _'uname -s'_'uname -r'

Where uname -s is the output of uname -s and uname -r is the output of uname -r with the invalid characters, such as periods (.), replaced by underscores, as in -D_ _SunOS_5_7 and -D_ _SunOS_5_8.

 

_ _unix

 

 

unix

See Interactions.

(SPARC)

_ _sparc

 

 

sparc

See Interactions.

(SPARC) v9

_ _sparcv9

64-bit compilation modes only

x86

_ _i386

 

 

i386

See Interactions.

UNIX

_WCHAR_T

 


If you do not use =def, name is defined as 1.

Interactions

If +p is used, sun, unix, sparc, and i386 are not defined.

See also

-U

A.2.10 -d{y|n}

Allows or disallows dynamic libraries for the entire executable.

This option is passed to ld.

This option can appear only once on the command line.

Values

Value

Meaning

-dy

Specifies dynamic linking in the link editor.

-dn

Specifies static linking in the link editor.


Defaults

If no -d option is specified, -dy is assumed.

Interactions

In a 64-bit environment, many system libraries are available only as shared dynamic libraries. These include libm.so and libc.so (libm.a and libc.a are not provided). As a result, -Bstatic and -dn may cause linking errors in 64-bit Solaris operating systems. Applications must link with the dynamic libraries in these cases.

Warnings

This option causes fatal errors if you use it in combination with dynamic libraries. Most system libraries are only available as dynamic libraries.

See also

ld(1), Linker and Libraries Guide

A.2.11 -dalign

-dalign is equivalent to -xmemalign=8s. See Section A.2.139, -xmemalign=ab for more information.

Warnings

If you compile one program unit with -dalign, compile all units of a program with -dalign, or you might get unexpected results.

A.2.12 -dryrun

Shows the subcommands built by driver, but does not compile.

This option directs the CC driver to show, but not execute, the subcommands constructed by the compilation driver.

A.2.13 -E

Runs the preprocessor on source files; does not compile.

Directs the CC driver to run only the preprocessor on C++ source files, and to send the result to stdout (standard output). No compilation is done; no .o files are generated.

This option causes preprocessor-type line number information to be included in the output.

Examples

This option is useful for determining the changes made by the preprocessor. For example, the following program, foo.cc, generates the output shown in CODE EXAMPLE A-2.


CODE EXAMPLE A-1 Preprocessor Example Program foo.cc
#if __cplusplus < 199711L
int power(int, int);
#else
template <> int power(int, int);
#endif
 
int main () {
  int x;
  x=power(2, 10);
}

CODE EXAMPLE A-2 Preprocessor Output of foo.cc Using -E Option
example% CC -E foo.cc
#4 "foo.cc"
template < > int power (int, int); 
 
 
int main () {
int x; 
x = power (2, 10); 
} 

 
Warnings

Output from this option is not supported as input to the C++ compiler when templates are used.

See also

-P

A.2.14 +e{0|1}

Controls virtual table generation in compatibility mode (-compat[=4]). Invalid and ignored when in standard mode (the default mode).

Values

The +e option can have the following values.


Value

Meaning

0

Suppresses the generation of virtual tables and creates external references to those that are needed.

1

Creates virtual tables for all defined classes with virtual functions.


Interactions

When you compile with this option, also use the -features=no%except option. Otherwise, the compiler generates virtual tables for internal types used in exception handling.

If template classes have virtual functions, ensuring that the compiler generates all needed virtual tables, but does not duplicate these tables, might not be possible.

See also

C++ Migration Guide

A.2.15 -erroff[=t]

This command suppresses C++ compiler warning messages and has no effect on error messages. This option applies to all warning messages whether or not they have been designated by -errwarn to cause a non-zero exit status.

Values

t is a comma-separated list that consists of one or more of the following: tag, no%tag, %all, %none. Order is important; for example, %all,no%tag suppresses all warning messages except tag. The following table lists the -erroff values:


TABLE A-4 The -erroff Values

Value

Meaning

tag

Suppresses the warning message specified by this tag. You can display the tag for a message by using the -errtags=yes option.

no%tag

Enables the warning message specified by this tag.

%all

Suppresses all warning messages.

%none

Enables all warning messages (default).


Defaults

The default is -erroff=%none. Specifying -erroff is equivalent to specifying -erroff=%all.

Examples

For example, -erroff=tag suppresses the warning message specified by this tag. On the other hand, -erroff=%all,no%tag suppresses all warning messages except the messages identified by tag.

You can display the tag for a warning message by using the -errtags=yes option.

Warnings

Only warning messages from the C++ compiler front-end that display a tag when the -errtags option is used can be suppressed with the -erroff option.

See Also

-errtags, -errwarn

A.2.16 -errtags[=a]

Displays the message tag for each warning message of the C++ compiler front-end that can be suppressed with the -erroff option or made a fatal warning with the -errwarn option.

Values and Defaults

a can be either yes or no. The default is -errtags=no. Specifying -errtags is equivalent to specifying -errtags=yes.

Warnings

Messages from the C++ compiler driver and other components of the compilation system do not have error tags, and cannot be suppressed with -erroff or made fatal with -errwarn.

See Also

-erroff, -errwarn

A.2.17 -errwarn[=t]

Use -errwarn to cause the C++ compiler to exit with a failure status for the given warning messages.

Values

t is a comma-separated list that consists of one or more of the following: tag, no%tag, %all, %none. Order is important; for example %all,no%tag causes cc to exit with a fatal status if any warning except tag is issued.

The following table details the -errwarn values:


TABLE A-5 The -errwarn Values

Value

Meaning

tag

Cause CC to exit with a fatal status if the message specified by this tag is issued as a warning message. Has no effect if tag is not issued.

no%tag

Prevent CC from exiting with a fatal status if the message specified by tag is issued only as a warning message. Has no effect if the message specified by tag is not issued. Use this option to revert a warning message that was previously specified by this option with tag or %all from causing cc to exit with a fatal status when issued as a warning message.

%all

Cause CC to exit with a fatal status if any warning messages are issued. %all can be followed by no%tag to exempt specific warning messages from this behavior.

%none

Prevents any warning message from causing CC to exit with a fatal status should any warning message be issued.


Defaults

The default is -errwarn=%none. If you specify -errwarn alone, it is equivalent to -errwarn=%all.

Warnings

Only warning messages from the C++ compiler front-end that display a tag when the -errtags option is used can be specified with the -errwarn option to cause the compiler to exit with a failure status.

The warning messages generated by the C++ compiler change from release to release as the compiler error checking improves and features are added. Code that compiles using -errwarn=%all without error may not compile without error in the next release of the compiler.

See Also

-erroff, -errtags

A.2.18 -fast

This option is a macro that can be effectively used as a starting point for tuning an executable for maximum runtime performance. -fast is a macro that can change from one release of the compiler to the next and expands to options that are target platform specific. Use the -# option or -xdryrun to examine the expansion of -fast, and incorporate the appropriate options of -fast into the ongoing process of tuning the executable.

This option is a macro that selects a combination of compilation options for optimum execution speed on the machine upon which the code is compiled.

Expansions

This option provides near maximum performance for many applications by expanding to the following compilation options.


TABLE A-6 The -fast Expansion

Option

SPARC

x86

-fns

X

X

-fsimple=2

X

X

-nofstore

-

X

-xlibmil

X

X

-xlibmopt

X

X

-xmemalign

X

-

-xO5

X

X

-xtarget=native

X

X

-xbuiltin=%all

X

X


Interactions

The -fast macro expands into compilation options that may affect other specified options. For example, in the following command, the expansion of the -fast macro includes -xtarget=native which reverts -xarch to one of the 32-bit architecture options.

Incorrect:


example% CC -xarch=v9 -fast test.cc

Correct:


example% CC -fast -xarch=v9 test.cc

See the description for each option to determine possible interactions.

The code generation option, the optimization level, the optimization of built-in functions, and the use of inline template files can be overridden by subsequent options (see examples). The optimization level that you specify overrides a previously set optimization level.

The -fast option includes -fns -ftrap=%none; that is, this option turns off all trapping.

Examples

The following compiler command results in an optimization level of -xO3.


example% CC -fast -xO3

The following compiler command results in an optimization level of -xO5.


example% CC -xO3 -fast

Warnings

If you compile and link in separate steps, the -fast option must appear in both the compile command and the link command.

Code that is compiled with the -fast option is not portable. For example, using the following command on an UltraSPARC III system generates a binary that will not execute on an UltraSPARC II system.


example% CC -fast test.cc

Do not use this option for programs that depend on IEEE standard floating-point arithmetic; different numerical results, premature program termination, or unexpected SIGFPE signals can occur.

In previous SPARC releases, the -fast macro expanded to -fsimple=1. Now it expands to -fsimple=2.

In previous releases, the -fast macro expanded to -xO4. Now it expands to -xO5.



Note - In previous SPARC releases, the -fast macro option included -fnonstd; now it does not. Nonstandard floating-point mode is not initialized by -fast. See the Numerical Computation Guide, ieee_sun(3M).



See also

-fns, -fsimple, -ftrap=%none, -xlibmil, -nofstore, -xO5, -xlibmopt, -xtarget=native

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

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

Values

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


TABLE A-7 The -features Values for Compatibility Mode and Standard Mode

Value of a

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 Section 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.

[no%]extensions

[Do not] allow nonstandard code that is commonly accepted by other C++ compilers. See Chapter 4 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-8 The -features Values for Standard Mode Only

Value of a

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 compatibility mode (-compat[=4]), a can have the following additional values.


TABLE A-9 The -features Values for Compatibility Mode Only

Value of a

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 compiler versions 5.0, 5.1, 5.2 and 5.3. 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 following 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

Chapter 4 and the C++ Migration Guide

A.2.20 -filt[=filter[,filter...]]

Controls the filtering that the compiler normally applies to linker and compiler error messages.

Values

filter must be one of the following values.


TABLE A-10 The -filt Values

Value of filter

Meaning

[no%]errors

[Do not] Show the C++ explanations of the linker error messages. The suppression of the explanations is useful when the linker diagnostics are provided directly to another tool.

[no%]names

[Do not] Demangle the C++ mangled linker names.

[no%]returns

[Do not] Demangle the return types of functions. Suppression of this type of demangling helps you to identify function names more quickly, but note that in the case of co-variant returns some functions differ only in the return type.

[no%]stdlib

[Do not] Simplify names from the standard library in both the linker and compiler error messages. This makes it easier for you to recognize the names of standard library template types.

%all

Equivalent to -filt=errors,names,returns,stdlib. This is the default behavior.

%none

Equivalent to -filt=no%errors,no%names,no%returns,no%stdlib.


Defaults

If you do not specify the -filt option, or if you specify -filt without any values, then the compiler assumes -filt=%all.

Examples

The following examples show the effects of compiling this code with the -filt option.


// filt_demo.cc
class type {
public:
    virtual ~type(); // no definition provided
};
 
int main()
{
    type t;
}

When you compile the code without the -filt option, the compiler assumes -filt=errors,names,returns,stdlib and displays the standard output.


example% CC filt_demo.cc
Undefined             first referenced
 symbol                  in file
type::~type()         filt_demo.o
type::__vtbl          filt_demo.o
[Hint: try checking whether the first non-inlined, non-pure virtual function of class type is defined]
 
ld: fatal: Symbol referencing errors. No output written to a.out

The following command suppresses the demangling of the of the C++ mangled linker names and suppresses the C++ explanations of linker errors.


example% CC -filt=no%names,no%errors filt_demo.cc
Undefined                       first referenced
 symbol                             in file
__1cEtype2T6M_v_                    filt_demo.o
__1cEtypeG__vtbl_                   filt_demo.o
ld: fatal: Symbol referencing errors. No output written to a.out

Now consider this code:


#include <string>
#include <list>
int main()
{
    std::list<int> l;
    std::string s(l); // error here
}

Here's the output when you specify -filt=no%stdlib:


Error: Cannot use std::list<int, std::allocator<int>> to initialize 
std::basic_string<char, std::char_traits<char>, 
std::allocator<char>>.

Here's the output when you specify -filt=stdlib:


Error: Cannot use std::list<int> to initialize std::string .

Interactions

When you specify no%names, neither returns nor no%returns has an effect. That is, the following options are equivalent:

A.2.21 -flags

Same as -xhelp=flags.

A.2.22 -fnonstd

Causes hardware traps to be enabled for floating-point overflow, division by zero, and invalid operations exceptions. These results are converted into SIGFPE signals; if the program has no SIGFPE handler, it terminates with a memory dump (unless you limit the core dump size to 0).

SPARC: In addition, -fnonstd selects SPARC nonstandard floating point.

Defaults

If -fnonstd is not specified, IEEE 754 floating-point arithmetic exceptions do not abort the program, and underflows are gradual.

Expansions

x86: -fnonstd expands to -ftrap=common.

SPARC: -fnonstd expands to -fns -ftrap=common.

See also

-fns, -ftrap=common, Numerical Computation Guide.

A.2.23 -fns[={yes|no}]

-fns=yes (or -fns) causes the nonstandard floating point mode to be enabled when a program begins execution.

This option provides a way of toggling the use of nonstandard or standard floating-point mode following some other macro option that includes -fns, such as -fast.

On some SPARC devices, the nonstandard floating-point mode disables "gradual underflow," causing tiny results to be flushed to zero rather than to produce subnormal numbers. It also causes subnormal operands to be silently replaced by zero.

On those SPARC devices that do not support gradual underflow and subnormal numbers in hardware, -fns=yes (or -fns) can significantly improve the performance of some programs.

This option causes subnormal results to be flushed to zero. Where available, this option also causes subnormal operands to be treated as zero.

This option has no effect on traditional x86 floating-point operations that do utilize the SSE or SSE2 instruction set.

Values

The -fns option can have the following values.


TABLE A-11 The -fns Values

Value

Meaning

yes

Selects nonstandard floating-point mode

no

Selects standard floating-point mode


Defaults

If -fns is not specified, the nonstandard floating point mode is not enabled automatically. Standard IEEE 754 floating-point computation takes place--that is, underflows are gradual.

If only -fns is specified, -fns=yes is assumed.

Examples

In the following example, -fast expands to several options, one of which is -fns=yes which selects nonstandard floating-point mode. The subsequent -fns=no option overrides the initial setting and selects floating-point mode.


example% CC foo.cc -fast -fns=no

Warnings

When nonstandard mode is enabled, floating-point arithmetic can produce results that do not conform to the requirements of the IEEE 754 standard.

If you compile one routine with the -fns option, then compile all routines of the program with the -fns option; otherwise, you might get unexpected results.

This option is effective only on SPARC devices, and only if used when compiling the main program. On x86 devices, the option is ignored.

Use of the -fns=yes (or -fns) option might generate the following message if your program experiences a floating-point error normally managed by the IEEE floating-point trap handlers:

See also

Numerical Computation Guide, ieee_sun(3M)

A.2.24 -fprecision=p

x86: Sets the non-default floating-point precision mode.

The -fprecision option sets the rounding precision mode bits in the Floating Point Control Word. These bits control the precision to which the results of basic arithmetic operations (add, subtract, multiply, divide, and square root) are rounded.

Values

p must be one of the following values.


TABLE A-12 The -fprecision Values

Value of p

Meaning

single

Rounds to an IEEE single-precision value.

double

Rounds to an IEEE double-precision value.

extended

Rounds to the maximum precision available.


If p is single or double, this option causes the rounding precision mode to be set to single or double precision, respectively, when a program begins execution. If p is extended or the -fprecision option is not used, the rounding precision mode remains at the extended precision.

The single precision rounding mode causes results to be rounded to 24 significant bits, and double precision rounding mode causes results to be rounded to 53 significant bits. In the default extended precision mode, results are rounded to 64 significant bits. This mode controls only the precision to which results in registers are rounded, and it does not affect the range. All results in register are rounded using the full range of the extended double format. Results that are stored in memory are rounded to both the range and precision of the destination format, however.

The nominal precision of the float type is single. The nominal precision of the long double type is extended.

Defaults

When the -fprecision option is not specified, the rounding precision mode defaults to extended.

Warnings

This option is effective only on x86 devices and only if used when compiling the main program. On SPARC devices, this option is ignored.

A.2.25 -fround=r

Sets the IEEE rounding mode in effect at startup.

This option sets the IEEE 754 rounding mode that:

The meanings are the same as those for the ieee_flags subroutine, which can be used to change the mode at runtime.

Values

r must be one of the following values.


TABLE A-13 The -fround Values

Value of r

Meaning

nearest

Rounds towards the nearest number and breaks ties to even numbers.

tozero

Rounds to zero.

negative

Rounds to negative infinity.

positive

Rounds to positive infinity.


Defaults

When the -fround option is not specified, the rounding mode defaults to -fround=nearest.

Warnings

If you compile one routine with -fround=r, compile all routines of the program with the same -fround=r option; otherwise, you might get unexpected results.

This option is effective only if used when compiling the main program.

A.2.26 -fsimple[=n]

Selects floating-point optimization preferences.

This option allows the optimizer to make simplifying assumptions concerning floating-point arithmetic.

Values

If n is present, it must be 0, 1, or 2.


TABLE A-14 The -fsimple Values

Value of n

Meaning

0

Permit no simplifying assumptions. Preserve strict IEEE 754 conformance.

1

Allow conservative simplification. The resulting code does not strictly conform to IEEE 754, but numeric results of most programs are unchanged.

With -fsimple=1, the optimizer can assume the following:

  • IEEE754 default rounding/trapping modes do not change after process initialization.
  • Computation producing no visible result other than potential floating-point exceptions can be deleted.
  • Computation with infinities or NaNs as operands needs to propagate NaNs to their results; that is, x*0 can be replaced by 0.
  • Computations do not depend on sign of zero.

With -fsimple=1, the optimizer is not allowed to optimize completely without regard to roundoff or exceptions. In particular, a floating-point computation cannot be replaced by one that produces different results when rounding modes are held constant at runtime.

2

Permit aggressive floating-point optimization that can cause many programs to produce different numeric results due to changes in rounding. For example, permit the optimizer to replace all computations of x/y in a given loop with x*z, where x/y is guaranteed to be evaluated at least once in the loop z=1/y, and the values of y and z are known to have constant values during execution of the loop.


Defaults

If -fsimple is not designated, the compiler uses -fsimple=0.

If -fsimple is designated but no value is given for n, the compiler uses -fsimple=1.

Interactions

-fast implies -fsimple=2.

Warnings

This option can break IEEE 754 conformance.

See also

-fast

Techniques for Optimizing Applications: High Performance Computing written by Rajat Garg and Ilya Sharapov for a more detailed explanation of how optimization can impact precision.

A.2.27 -fstore

x86: This option causes the compiler to convert the value of a floating-point expression or function to the type on the left side of an assignment rather than leave the value in a register when the following is true: