A P P E N D I X  A

C++ Compiler Options

This appendix details the command-line options for the CC compiler running under Solaris 7 and Solaris 8. The features described apply to all platforms except as noted; features that are unique to the Solaris SPARC Platform Edition operating environment are identified as SPARC, and the features that are unique to the Solaris Intel Platform Edition operating environment are identified as IA.

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

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

A.2.2 -486

IA: 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 - On the Solaris 7 and Solaris 8 platforms, not all libraries are available as static libraries.



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

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.

Regardless of the -compat setting, _ _SUNPRO_CC is set to 0x540.

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.

  • -Bsymbolic when the library has exceptions in it
  • -features=[no%]strictdestrorder
  • -features=[no%]tmplife
  • -library=[no%]iostream
  • -library=[no%]Cstd
  • -library=[no%]Crun
  • -library=[no%]rwtools7_std
  • -xarch=native64, -xarch=generic64, -xarch=v9, -xarch=v9a, or -xarch=v9b

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

  • +e
  • features=[no%]arraynew
  • features=[no%]explicit
  • features=[no%]namespace
  • features=[no%]rtti
  • library=[no%]complex
  • library=[no%]libC
  • -vdelx
Warnings

When building a shared library in compatibility mode (-compat[=4]), do not use -Bsymbolic if the library has exceptions in it. Exceptions that should be caught might be missed.

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.

  • The function is defined using the inline keyword,
  • The function is defined (not just declared) inside a class definition
  • The function is a compiler-generated class member function

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:

  • The function is too complex,
  • The +d option is selected, or
  • The -g option is selected
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 Predefined Macros

Type

Macro Name

Notes

SPARC and IA

_ _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_ _

 

 

_ _sun

 

 

sun

See Interactions.

 

_ _SUNPRO_CC=0x540

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}]

 

_ _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

IA

_ _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 environments. Applications must link with the dynamic libraries in these cases.

See also

ld(1), Linker and Libraries Guide

A.2.11 -dalign

SPARC: Generates double-word load and store instructions whenever possible for improved performance.

This option assumes that all double type data are double-word aligned.

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 driver CC 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 -fast

Optimizes for speed of execution using a selection of options.

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-4 -fast Expansion

Option

SPARC

IA

-dalign

X

-

-fns

X

X

-fsimple=2

X

-

-ftrap=%none

X

X

-nofstore

-

X

-xarch

X

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

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

A.2.16 -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-5 -features Options for Compatibility Mode and Standard Mode

Value of a

Meaning

%all

All the -features options that are valid for the specified 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-6 -features Options 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%]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-7 -features Options 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. The default is no%rtti.




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:

  • Compatibility mode (-compat[=4])
  • -features=%none,anachronisms,except,split_init,transitions
    

  • Standard mode (the default mode)
  • -features=%all,no%iddollar,no%extensions
    

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:

  • no%bool
  • no%except
  • no%mutable
  • no%explicit
Interactions

This option accumulates instead of overrides.

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

Warnings

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. 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.17 -filt[=filter[,filter...]]

Suppress the filtering that the compiler normally applies to linker error messages.

filter must be one of the following values.

TABLE A-8 -filt Options

Value of filter

Meaning

[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%]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.

%all

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

%none

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


Defaults

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

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=names,returns,errors 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

Interactions

When you specify no%names, neither returns nor no%returns has an effect.

A.2.18 -flags

Same as -xhelp=flags.

A.2.19 -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

IA: -fnonstd expands to -ftrap=common.

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

See also

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

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

SPARC: Enables/disables the SPARC nonstandard floating-point mode.

-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. (See "Examples.")

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.

Values

The -fns option can have the following 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 IA 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.21 -fprecision=p

IA: 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.

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 IA devices and only if used when compiling the main program. On SPARC devices, this option is ignored.

A.2.22 -fround=r

Sets the IEEE rounding mode in effect at startup.

This option sets the IEEE 754 rounding mode that:

  • Can be used by the compiler in evaluating constant expressions
  • Is established at runtime during the program initialization

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.

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

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

A.2.24 -fstore

IA: 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:

  • The expression or function is assigned to a variable.
  • The expression is cast to a shorter floating-point type.

To turn off this option, use the -nofstore option.

Warnings

Due to roundoffs and truncation, the results can be different from those that are generated from the register values.

See also

-nofstore

A.2.25 -ftrap=t[,t...]

Sets the IEEE trapping mode in effect at startup.

This option sets the IEEE 754 trapping modes that are established at program initialization, but does not install a SIGFPE handler. You can use ieee_handler to simultaneously enable traps and install a SIGFPE handler. When more than one value is used, the list is processed sequentially from left to right.

Values

t can be one of the following values.

Value of t

Meaning

[no%]division

[Do not] Trap on division by zero.

[no%]inexact

[Do not] Trap on inexact result.

[no%]invalid

[Do not] Trap on invalid operation.

[no%]overflow

[Do not] Trap on overflow.

[no%]underflow

[Do not] Trap on underflow.

%all

Trap on all of the above.

%none

Trap on none of the above.

common

Trap on invalid, division by zero, and overflow.


Note that the [no%] form of the option is used only to modify the meaning of the %all and common values, and must be used with one of these values, as shown in the example. The [no%] form of the option by itself does not explicitly cause a particular trap to be disabled.

If you want to enable the IEEE traps, -ftrap=common is the recommended setting.

Defaults

If -ftrap is not specified, the -ftrap=%none value is assumed. (Traps are not enabled automatically.)

Examples

When one or more terms are given, the list is processed sequentially from left to right, thus -ftrap=%all,no%inexact means to set all traps except inexact.

Interactions

The mode can be changed at runtime with ieee_handler(3M).

Warnings

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

Use the -ftrap=inexact trap with caution. Use of -ftrap=inexact results in the trap being issued whenever a floating-point value cannot be represented exactly. For example, the following statement generates this condition:

x = 1.0 / 3.0;

This option is effective only if used when compiling the main program. Be cautious when using this option. If you wish to enable the IEEE traps, use -ftrap=common.

See also

ieee_handler(3M) man page

A.2.26 -G

Build a dynamic shared library instead of an executable file.

All source files specified in the command line are compiled with -Kpic by default.

When building a shared library that uses templates, it is necessary in most cases to include in the shared library those template functions that are instantiated in the template data base. Using this option automatically adds those templates to the shared library as needed.

Interactions

The following options are passed to ld if -c (the compile-only option) is not specified:

  • -dy
  • -G
  • -R
Warnings

Do not use ld -G to build shared libraries; use CC -G. The CC driver automatically passes several options to ld that are needed for C++.

When you use the -G option, the compiler does not pass any default -l options to ld. If you want the shared library to have a dependency on another shared library, you must pass the necessary -l option on the command line. For example, if you want the shared library to be dependent upon libCrun, you must pass -lCrun on the command line.

See also

-dy, -Kpic, -xcode=pic13, -xildoff, -ztext, ld(1) man page, Section 16.3, Building Dynamic (Shared) Libraries.

A.2.27 -g

Produces additional symbol table information for debugging with dbx(1) or the Debugger and for analysis with the Performance Analyzer analyzer(1).

Instructs both the compiler and the linker to prepare the file or program for debugging and for performance analysis.

The tasks include:

  • Producing detailed information, known as stabs, in the symbol table of the object files and the executable
  • Producing some "helper functions," which the debugger can call to implement some of its features
  • Disabling the inline generation of functions
  • Disabling certain levels of optimization
Interactions

If you use this option with -xOlevel (or its equivalent options, such as -O), you will get limited debugging information. For more information, see Section A.2.131, -xOlevel.

If you use this option and the optimization level is -xO3 or lower, the compiler provides best-effort symbolic information with almost full optimization. Tail-call optimization and back-end inlining are disabled.

If you use this option and the optimization level is -xO4 or higher, the compiler provides best-effort symbolic information with full optimization.

When you specify this option, the +d option is specified automatically.

This option makes -xildon the default incremental linker option in order to speed up the compile-edit-debug cycle.

This option invokes ild in place of ld unless any of the following are true:

  • The -G option is present
  • The -xildoff option is present
  • Any source files are named on the command line

To use the full capabilities of the Performance Analyzer, compile with the -g option. While some performance analysis features do not require -g, you must compile with -g to view annotated source, some function level information, and compiler commentary messages. See the analyzer(1) man page and "Compiling Your Program for Data Collection and Analysis" in Program Performance Analysis Tools for more information.

The commentary messages that are generated with -g describe the optimizations and transformations that the compiler made while compiling your program. Use the er_src(1) command to display the messages, which are interleaved with the source code.

Warnings

If you compile and link your program in separate steps, then including the -g option in one step and excluding it from the other step will not affect the correctness of the program, but it will affect the ability to debug the program. Any module that is not compiled with -g (or -g0), but is linked with -g (or -g0) will not be prepared properly for debugging. Note that compiling the module that contains the function main with the -g option (or the -g0 option) is usually necessary for debugging.

See also

+d, -g0, -xildoff, -xildon, -xs, analyzer(1) man page, er_src(1) man page, ld(1) man page, Debugging a Program With dbx (for details about stabs), Program Performance Analysis Tools.

A.2.28 -g0

Compiles and links for debugging, but does not disable inlining.

This option is the same as -g, except that +d is disabled.

See also

+d, -g, -xildon, Debugging a Program With dbx

A.2.29 -H

Prints path