C++ User's Guide

Options Summarized by Function

In this section, the compiler options are grouped by function to provide a quick reference.

Code Generation Options

The following code generation options are listed in alphabetical order.

Action 

Option 

Details  

Sets the major release compatibility mode of the compiler. 

-compat

"-compat[=(4|5)]"

Does not expand C++ inline functions. 

+d

"+d"

Controls virtual table generation. 

+e(0|1)

"+e(0|1)"

Compiles for use with the debugger. 

-g

"-g"

Produces position-independent code. 

-KPIC

" -KPIC "

Produces position-independent code. 

-Kpic

"-Kpic "

Compiles and links for multithreaded code. 

-mt

"-mt"

Specifies the code address space. 

-xcode=a

"-xcode=a"

Merges the data segment with the text segment. 

-xMerge

"-xMerge"

Debugging Options

The following debugging options are listed in alphabetical order.

Action 

Option 

Details  

Does not expand C++ inline functions. 

+d

"+d"

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

-dryrun

"-dryrun"

Runs the preprocessor on source files; does not compile. 

-E

"-E"

Displays a summary list of compiler options. 

-flags

"-flags"

Compiles for use with the debugger. 

-g

"-g"

Compiles for debugging, but doesn't disable inlining. 

-g0

"-g0"

Prints path names of included files. 

-H

"-H"

Displays a summary list of compiler options. 

-help

"-help"

Retains temporary files created during compilation. 

-keeptmp

"-keeptmp"

Explains where to get information about migrating to 5.0 

-migration

"-migration"

Only preprocesses source; outputs to .i file.

-P

"-P"

Passes an option directly to a compilation phase. 

-Qoption

"-Qoption phase option[,...option]"

Displays the content of the online README file.

-readme

"-readme"

Strips the symbol table out of the executable file. 

-s

"-s"

Defines directory for temporary files. 

-temp=dir

"-temp=dir"

Controls compiler verbosity. 

-verbose=vlst

"-verbose=v[,...v]"

Turns off the Incremental Linker. 

-xildoff

"-xildoff"

Turns on the Incremental Linker. 

-xildon

"-xildon"

Allows debugging with dbx without object (.o) files.

-xs

"-xs"

Produces table information for the WorkShop source code browser. 

-xsb

"-xsb"

Produces only source browser information, no compilation.

-xsbfast

"-xsbfast"

Floating-Point Options

The following floating-point options are listed in alphabetical order.

Action 

Option 

Details  

Disables/enables the SPARC nonstandard floating-point mode. 

-fns[=(no|yes)]

"-fns[=(yes|no)] "

x86: Sets floating-point precision mode.

-fprecision=p

"-fprecision=p"

Sets IEEE rounding mode in effect at start-up. 

-fround=r

"-fround=r"

Sets floating-point optimization preferences. 

-fsimple=n

"-fsimple[=n]"

x86: Forces precision of floating-point expressions.

-fstore

"-fstore"

Sets IEEE trapping mode in effect at start-up. 

-ftrap=t

"-ftrap=t"

x86: Disables forced precision of expression.

-nofstore

"-nofstore"

Causes libm to return IEEE 754 values for math routines in exceptional cases.

-xlibmieee

"-xlibmieee"

Language Options

The following language options are listed in alphabetical order.

Action 

Option 

Details  

Sets the major release compatibility mode of the compiler. 

-compat

"-compat[=(4|5)]"

Enables/disables various C++ language features. 

-features=alst

"-features=a[,...a]"

Library Options

The following library linking options are listed in alphabetical order.

Action 

Option 

Details  

Allows dynamic static library linking. 

-Bbinding

"-Bbinding"

Allows or disallows dynamic libraries for the entire executable. 

-d(y|n)

"-d(y|n)"

Builds a dynamic shared library instead of an executable file. 

-G

"-G"

Assigns a name to the generated dynamic shared library.

-hname

"-hname"

Tells ld(1) to ignore any LD_LIBRARY_PATH setting.

-i

"-i"

Adds dir to the list of directories to be searched for libraries.

-Ldir

"-Ldir"

Adds liblib.a or liblib.so to the linker's library search list.

-llib

"-llib"

Forces inclusion of specific libraries and associated files into compilation and linking. 

-library=llst

"-library=l[,...l]"

Compiles and links for multithreaded code. 

-mt

"-mt"

Does not build path for libraries into executable. 

-norunpath

"-norunpath"

Builds dynamic library search paths into the executable file. 

-R pathname

"-Rpathname"

Indicates which C++ libraries are to be linked statically. 

-staticlib=llst

"-staticlib=l[,...l]"

Creates archive libraries. 

-xar

"-xar"

Causes libm to return IEEE 754 values for math routines in exceptional cases.

-xlibmieee

"-xlibmieee"

Inlines selected libm library routines for optimization.

-xlibmil

"-xlibmil"

Uses library of optimized math routines. 

-xlibmopt

"-xlibmopt"

Links with the specified, Sun-supplied, licensed libraries. 

-xlic_lib=llst

"-xlic_lib=l[,...l]"

Disables linking with default system libraries. 

-xnolib

"-xnolib"

Cancels -xlibmil on the command line.

-xnolibmil

"-xnolibmil"

Does not use the math routine library. 

-xnolibmopt

"-xnolibmopt"

Forces fatal error if relocations remain against non-writable, allocatable sections. 

-ztext

"-ztext"

Licensing Options

The following licensing options are listed in alphabetical order.

Action 

Option 

Details  

Disables license queueing. 

-noqueue

"-noqueue"

Links with the specified, Sun-supplied, licensed libraries. 

-xlic_lib=llst

"-xlic_lib=l[,...l]"

Shows license server information. 

-xlicinfo

"-xlicinfo"

Obsolete Options

Action 

Option 

Details 

See details. 

-vdelx

"-vdelx"

Output Options

The following output options are listed in alphabetical order.

Action 

Option 

Details  

Compiles only; produces object (.o) files, but suppresses linking.

-c

"-c"

Shows options passed by driver to the compiler, but does not compile. 

-dryrun

"-dryrun"

Runs only preprocessor on C++ source files, and sends result to stdout; does not compile.

-E

"-E"

Same as -help.

-flags

"-flags"

Builds a dynamic shared library instead of an executable file. 

-G

"-G"

Prints path names of included files. 

-H

"-H"

Explains where to get information about migrating to 5.0 

-migration

"-migration"

Sets name of the output or executable file to filename.

-o filename

"-o filename"

Only preprocesses source; outputs to .i file.

-P

"-P"

Causes the CC driver to produce output of the type sourcetype.

-Qproduce sourcetype

"-Qproduce sourcetype"

Displays the contents of the online README file.

-readme

"-readme"

Strips the symbol table from the executable file. 

-s

"-s"

Controls compiler verbosity. 

-verbose=vlst

"-verbose=v[,...v]"

Prints extra warnings where necessary. 

+w

"+w"

Suppresses warning messages. 

-w

"-w"

Outputs makefile dependency information. 

-xM

"-xM"

Generates dependency information, but excludes 

/usr/include.

-xM1

"-xM1"

Produces table information for the Sun WorkShop source code browser. 

-xsb

"-xsb"

Produces only source browser information, no compilation.

-xsbfast

"-xsbfast"

Reports execution time for each compilation phase. 

-xtime

"-xtime"

Converts all warnings to errors by returning non-zero exit status. 

-xwe

"-xwe"

Performance Options

The following performance options are listed in alphabetical order.

Action 

Option 

Details  

Selects a combination of compilation options for optimum execution speed. 

-fast

"-fast"

Strips the symbol table out of the executable. 

-s

"-s"

Specifies target architecture instruction set. 

-xarch=a

"-xarch=a"

SPARC: Defines target cache properties for the optimizer.

-xcache=c

"-xcache=c"

Compiles for generic SPARC architecture. 

-xcg89

"-xcg(89|92)"

Compiles for SPARC V8 architecture. 

-xcg92

"-xcg(89|92)"

Specifies target processor chip. 

-xchip=c

"-xchip=c"

Enables linker reordering of functions. 

-xF

"-xF"

Inlines the specified routines to optimize for speed. 

-xinline=rlst

"-xinline=f[,...f]"

Inlines selected libm library routines for optimization.

-xlibmil

"-xlibmil"

SPARC: Uses a library of optimized math routines.

-xlibmopt

"-xlibmopt"

Cancels -xlibmil on the command line.

-xnolibmil

"-xnolibmil"

Does not use math library routines. 

-xnolibmopt

"-xnolibmopt"

Specifies optimization level to level.

-xOlevel

"-xO[level]"

SPARC: Controls scratch register use.

-xregs=rlst

"-xregs=r[,...r] "

SPARC: Allows no memory-based traps.

-xsafe=mem

"-xsafe=mem"

SPARC: Does not allow optimizations that increase code size.

-xspace

"-xspace"

Specifies a target instruction set and optimization system. 

-xtarget=t

"-xtarget=t"

Enables unrolling of loops where possible. 

-xunroll=n

"-xunroll=n"

Preprocessor Options

The following preprocessor options are listed in alphabetical order.

Action 

Option 

Details  

Defines symbol name to the preprocessor.

-Dname[=def]

"-Dname[=def]"

Runs preprocessor on C++ source files and sends result to stdout. Does not compile.

-E

"-E"

Only preprocesses source; outputs to .i file.

-P

"-P"

Deletes initial definition of preprocessor symbol name.

-Uname

"-Uname"

Outputs makefile dependency information. 

-xM

"-xM"

Generates dependency information, but excludes 

/usr/include.

-xM1

"-xM1"

Profiling Options

The following profiling options are listed in alphabetical order.

Action 

Option 

Details  

Prepares the object code to collect data for profiling with prof.

-p

"-p"

Generates code for profiling. 

-xa

"-xa"

Compiles for profiling with the gprof profiler.

-xpg

"-xpg"

Collects or optimizes with runtime profiling data. 

-xprofile=tcov

"-xprofile=p"

Reference Options

The following options provide a quick reference to compiler information.

Action 

Option 

Details  

Displays a summary list of compiler options. 

-flags

"-help"

Displays a summary list of compiler options. 

-help

"-help"

Displays information about migrating to 5.0 

-migration

"-migration"

Displays the contents of the online README file.

-readme

"-readme"

Source Options

The following source options are listed in alphabetical order.

Action 

Option 

Details  

Adds pathname to the include file search path

-Ipathname

"-Ipathname"

Outputs makefile dependency information. 

-xM

"-xM"

Generates dependency information, but excludes 

/usr/include.

-xM1

"-xM1"

Template Options

The following template options are listed in alphabetical order.

Action 

Option 

Details  

Controls the placement and linkage of template instances. 

-instances=a

"-instances=a "

Specifies an additional search directory for template source 

-ptipath

"-ptipath"

Specifies the directory of the template repository. 

-ptrdirectory

"-ptrdatabase-path"

Enables/disables various template options. 

-template=w

"-template=w"

Thread Options

The following thread options are listed in alphabetical order.

Action 

Option 

Details  

Compiles and links for multithreaded code. 

-mt

"-mt"

SPARC: Allows no memory-based traps.

-xsafe=mem

"-xsafe=mem"

How Option Information Is Organized

To facilitate your information search, compiler option information has been 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.

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. For example, the -xinline option should not be used if -xO is less than 3.

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," or "Use" 

If an option has become obsolete and been replaced by another, or the use of one option is preferred over another, the replacement option is noted here. For example, "Replace with -xO" or "Use -xO" means that -xO is the preferred option. Options described this way may not be supported in future releases.

 

If one option is an abbreviation for a longer option, the expansion is shown with "Same as." 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.