Documentation Home
> Sun Studio 12: C++ User's Guide
Sun Studio 12: C++ User's Guide
Book Information
Index
Numbers and Symbols
A
B
C
D
E
F
G
H
I
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Preface
Part I C++ Compiler
Chapter 1 The C++ Compiler
1.1 New Features and Functionality of the Sun Studio 12 C++ 5.9 Compiler
1.1.1 Compiling for 64–Bit Platforms
1.1.2 Special x86 Notes
1.1.3 Binary Compatibility Verification
1.2 Standards Conformance
1.3 C++ Readme File
1.4 Man Pages
1.5 C++ Utilities
1.6 Native-Language Support
Chapter 2 Using the C++ Compiler
2.1 Getting Started
2.2 Invoking the Compiler
2.2.1 Command Syntax
2.2.2 File Name Conventions
2.2.3 Using Multiple Source Files
2.3 Compiling With Different Compiler Versions
2.4 Compiling and Linking
2.4.1 Compile-Link Sequence
2.4.2 Separate Compiling and Linking
2.4.3 Consistent Compiling and Linking
2.4.4 Compiling for SPARC V9
2.4.5 Diagnosing the Compiler
2.4.6 Understanding the Compiler Organization
2.5 Preprocessing Directives and Names
2.5.1 Pragmas
2.5.2 Macros With a Variable Number of Arguments
2.5.3 Predefined Names
2.5.4 #error
2.6 Memory Requirements
2.6.1 Swap Space Size
2.6.2 Increasing Swap Space
2.6.3 Control of Virtual Memory
2.6.4 Memory Requirements
2.7 Simplifying Commands
2.7.1 Using Aliases Within the C Shell
2.7.2 Using CCFLAGS to Specify Compile Options
2.7.3 Using make
2.7.3.1 Using CCFLAGS Within make
2.7.3.2 Adding a Suffix to Your Makefile
2.7.3.3 Using make With Standard Library Header Files
Chapter 3 Using the C++ Compiler Options
3.1 Syntax
3.2 General Guidelines
3.3 Options Summarized by Function
3.3.1 Code Generation Options
3.3.2 Compile-Time Performance Options
3.3.3 Compile-Time and Link-Time Options
3.3.4 Debugging Options
3.3.5 Floating-Point Options
3.3.6 Language Options
3.3.7 Library Options
3.3.8 Licensing Options
3.3.9 Obsolete Options
3.3.10 Output Options
3.3.11 Run-Time Performance Options
3.3.12 Preprocessor Options
3.3.13 Profiling Options
3.3.14 Reference Options
3.3.15 Source Options
3.3.16 Template Options
3.3.17 Thread Options
Part II Writing C++ Programs
Chapter 4 Language Extensions
4.1 Linker Scoping
4.2 Thread-Local Storage
4.3 Overriding With Less Restrictive Virtual Functions
4.4 Making Forward Declarations of enum Types and Variables
4.5 Using Incomplete enum Types
4.6 Using an enum Name as a Scope Qualifier
4.7 Using Anonymous struct Declarations
4.8 Passing the Address of an Anonymous Class Instance
4.9 Declaring a Static Namespace-Scope Function as a Class Friend
4.10 Using the Predefined __func__ Symbol for Function Name
Chapter 5 Program Organization
5.1 Header Files
5.1.1 Language-Adaptable Header Files
5.1.2 Idempotent Header Files
5.2 Template Definitions
5.2.1 Template Definitions Included
5.2.2 Template Definitions Separate
Chapter 6 Creating and Using Templates
6.1 Function Templates
6.1.1 Function Template Declaration
6.1.2 Function Template Definition
6.1.3 Function Template Use
6.2 Class Templates
6.2.1 Class Template Declaration
6.2.2 Class Template Definition
6.2.3 Class Template Member Definitions
6.2.3.1 Function Member Definitions
6.2.3.2 Static Data Member Definitions
6.2.4 Class Template Use
6.3 Template Instantiation
6.3.1 Implicit Template Instantiation
6.3.2 Explicit Template Instantiation
6.3.2.1 Explicit Instantiation of Template Functions
6.3.2.2 Explicit Instantiation of Template Classes
6.3.2.3 Explicit Instantiation of Template Class Function Members
6.3.2.4 Explicit Instantiation of Template Class Static Data Members
6.4 Template Composition
6.5 Default Template Parameters
6.6 Template Specialization
6.6.1 Template Specialization Declaration
6.6.2 Template Specialization Definition
6.6.3 Template Specialization Use and Instantiation
6.6.4 Partial Specialization
6.7 Template Problem Areas
6.7.1 Nonlocal Name Resolution and Instantiation
6.7.2 Local Types as Template Arguments
6.7.3 Friend Declarations of Template Functions
6.7.4 Using Qualified Names Within Template Definitions
6.7.5 Nesting Template Names
6.7.6 Referencing Static Variables and Static Functions
6.7.7 Building Multiple Programs Using Templates in the Same Directory
Chapter 7 Compiling Templates
7.1 Verbose Compilation
7.2 Repository Administration
7.2.1 Generated Instances
7.2.2 Whole-Class Instantiation
7.2.3 Compile-Time Instantiation
7.2.4 Template Instance Placement and Linkage
7.3 External Instances
7.3.1 Possible Cache Conflicts
7.3.2 Static Instances
7.3.3 Global Instances
7.3.4 Explicit Instances
7.3.5 Semi-Explicit Instances
7.4 The Template Repository
7.4.1 Repository Structure
7.4.2 Writing to the Template Repository
7.4.3 Reading From Multiple Template Repositories
7.4.4 Sharing Template Repositories
7.4.5 Template Instance Automatic Consistency With -instances=extern
7.5 Template Definition Searching
7.5.1 Source File Location Conventions
7.5.2 Definitions Search Path
7.5.3 Troubleshooting a Problematic Search
Chapter 8 Exception Handling
8.1 Synchronous and Asynchronous Exceptions
8.2 Specifying Runtime Errors
8.3 Disabling Exceptions
8.4 Using Runtime Functions and Predefined Exceptions
8.5 Mixing Exceptions With Signals and Setjmp/Longjmp
8.6 Building Shared Libraries That Have Exceptions
Chapter 9 Cast Operations
9.1 const_cast
9.2 reinterpret_cast
9.3 static_cast
9.4 Dynamic Casts
9.4.1 Casting Up the Hierarchy
9.4.2 Casting to void*
9.4.3 Casting Down or Across the Hierarchy
Chapter 10 Improving Program Performance
10.1 Avoiding Temporary Objects
10.2 Using Inline Functions
10.3 Using Default Operators
10.4 Using Value Classes
10.4.1 Choosing to Pass Classes Directly
10.4.2 Passing Classes Directly on Various Processors
10.5 Cache Member Variables
Chapter 11 Building Multithreaded Programs
11.1 Building Multithreaded Programs
11.1.1 Indicating Multithreaded Compilation
11.1.2 Using C++ Support Libraries With Threads and Signals
11.2 Using Exceptions in a Multithreaded Program
11.2.1 Thread Cancellation
11.3 Sharing C++ Standard Library Objects Between Threads
11.4 Using Classic iostreams in a Multithreading Environment
11.4.1 Organization of the MT-Safe iostream Library
11.4.1.1 Public Conversion Routines
11.4.1.2 Compiling and Linking With the MT-Safe libC Library
11.4.1.3 MT-Safe iostream Restrictions
Checking Error State
Obtaining Characters Extracted by Last Unformatted Input Operation
User-Defined I/O Operations
11.4.1.4 Reducing Performance Overhead of MT-Safe Classes
11.4.2 Interface Changes to the iostream Library
11.4.2.1 The New Classes
11.4.2.2 The New Class Hierarchy
11.4.2.3 The New Functions
11.4.3 Global and Static Data
11.4.4 Sequence Execution
11.4.5 Object Locks
11.4.5.1 Class stream_locker
11.4.6 MT-Safe Classes
11.4.7 Object Destruction
11.4.8 An Example Application
Part III Libraries
Chapter 12 Using Libraries
12.1 The C Libraries
12.2 Libraries Provided With the C++ Compiler
12.2.1 C++ Library Descriptions
12.2.2 Accessing the C++ Library Man Pages
12.2.3 Default C++ Libraries
12.3 Related Library Options
12.4 Using Class Libraries
12.4.1 The iostream Library
12.4.2 The complex Library
12.4.3 Linking C++ Libraries
12.5 Statically Linking Standard Libraries
12.6 Using Shared Libraries
12.7 Replacing the C++ Standard Library
12.7.1 What Can Be Replaced
12.7.2 What Cannot Be Replaced
12.7.3 Installing the Replacement Library
12.7.4 Using the Replacement Library
12.7.5 Standard Header Implementation
12.7.5.1 Replacing Standard C++ Headers
12.7.5.2 Replacing Standard C Headers
Caveats:
Chapter 13 Using The C++ Standard Library
13.1 C++ Standard Library Header Files
13.2 C++ Standard Library Man Pages
13.3 STLport
13.3.1 Redistribution and Supported STLport Libraries
Chapter 14 Using the Classic iostream Library
14.1 Predefined iostreams
14.2 Basic Structure of iostream Interaction
14.3 Using the Classic iostream Library
14.3.1 Output Using iostream
14.3.1.1 Defining Your Own Insertion Operator
14.3.1.2 Handling Output Errors
14.3.1.3 Flushing
14.3.1.4 Binary Output
14.3.2 Input Using iostream
14.3.3 Defining Your Own Extraction Operators
14.3.4 Using the char* Extractor
14.3.5 Reading Any Single Character
14.3.6 Binary Input
14.3.7 Peeking at Input
14.3.8 Extracting Whitespace
14.3.9 Handling Input Errors
14.3.10 Using iostreams With stdio
14.4 Creating iostreams
14.4.1 Dealing With Files Using Class fstream
14.4.1.1 Open Mode
14.4.1.2 Declaring an fstream Without Specifying a File
14.4.1.3 Opening and Closing Files
14.4.1.4 Opening a File Using a File Descriptor
14.4.1.5 Repositioning Within a File
14.5 Assignment of iostreams
14.6 Format Control
14.7 Manipulators
14.7.1 Using Plain Manipulators
14.7.2 Parameterized Manipulators
14.8 Strstreams: iostreams for Arrays
14.9 Stdiobufs: iostreams for stdio Files
14.10 Streambufs
14.10.1 Working With Streambufs
14.10.1.1 Position of Pointers
14.10.2 Using Streambufs
14.11 iostream Man Pages
14.12 iostream Terminology
Chapter 15 Using the Complex Arithmetic Library
15.1 The Complex Library
15.1.1 Using the Complex Library
15.2 Type complex
15.2.1 Constructors of Class complex
15.2.2 Arithmetic Operators
15.3 Mathematical Functions
15.4 Error Handling
15.5 Input and Output
15.6 Mixed-Mode Arithmetic
15.7 Efficiency
15.8 Complex Man Pages
Chapter 16 Building Libraries
16.1 Understanding Libraries
16.2 Building Static (Archive) Libraries
16.3 Building Dynamic (Shared) Libraries
16.4 Building Shared Libraries That Contain Exceptions
16.5 Building Libraries for Private Use
16.6 Building Libraries for Public Use
16.7 Building a Library That Has a C API
16.8 Using dlopen to Access a C++ Library From a C Program
Part IV Appendixes
Appendix A C++ Compiler Options
A.1 How Option Information Is Organized
A.2 Option Reference
A.2.1 –386
A.2.2 –486
A.2.3 –a
A.2.4 –Bbinding
A.2.4.1 Values
Defaults
Interactions
Examples
Warnings
See also
A.2.5 –c
A.2.5.1 Examples
Warnings
See also
A.2.6 –cg{89|92}
A.2.7 –compat[={4|5}]
A.2.7.1 Values
Defaults
Interactions
Warnings
See also
A.2.8 +d
A.2.8.1 Examples
Interactions
See also
A.2.9 -Dname[=def]
A.2.9.1 Values
Interactions
See also
A.2.10 –d{y|n}
A.2.10.1 Values
Defaults
Interactions
Warnings
See also
A.2.11 –dalign
A.2.11.1 Warnings
A.2.12 –dryrun
A.2.13 –E
A.2.13.1 Examples
Warnings
See also
A.2.14 +e{0|1}
A.2.14.1 Values
Interactions
See also
A.2.15 -erroff[=t]
A.2.15.1 Values
Defaults
Examples
Warnings
See Also
A.2.16 -errtags[=a]
A.2.16.1 Values and Defaults
Warnings
See Also
A.2.17 -errwarn[=t]
A.2.17.1 Values
Defaults
Warnings
See Also
A.2.18 –fast
A.2.18.1 Expansions
Interactions
Examples
Warnings
See also
A.2.19 –features=a[,a...]
A.2.19.1 Values
Defaults
Interactions
Warnings
See also
A.2.20 -filt[=filter[,filter...]]
A.2.20.1 Values
Defaults
Examples
Interactions
A.2.21 –flags
A.2.22 -fma[={none|fused}]
A.2.23 –fnonstd
A.2.23.1 Defaults
Expansions
See also
A.2.24 –fns[={yes|no}]
A.2.24.1 Values
Defaults
Examples
Warnings
See also
A.2.25 –fprecision=p
A.2.25.1 Values
Defaults
Warnings
A.2.26 –fround=r
A.2.26.1 Values
Defaults
Warnings
A.2.27 –fsimple[=n]
A.2.27.1 Values
Defaults
Interactions
Warnings
See also
A.2.28 –fstore
A.2.28.1 Warnings
See also
A.2.29 –ftrap=t[,t...]
A.2.29.1 Values
Defaults
Examples
Warnings
See also
A.2.30 –G
A.2.30.1 Interactions
Warnings
See also
A.2.31 –g
A.2.31.1 Interactions
Warnings
See also
A.2.32 –g0
A.2.32.1 See also
A.2.33 –H
A.2.34 –h[ ]name
A.2.34.1 Examples
A.2.35 –help
A.2.36 -Ipathname
A.2.36.1 Interactions
Warnings
See also
A.2.37 -I-
A.2.37.1 Examples
Interactions
Warnings
A.2.38 –i
A.2.39 -inline
A.2.40 –instances=a
A.2.40.1 Values
Defaults
See also
A.2.41 –instlib=filename
A.2.41.1 Values:
Defaults:
Example:
Interactions:
Warning
See Also:
A.2.42 –KPIC
A.2.43 –Kpic
A.2.44 –keeptmp
A.2.44.1 See also
A.2.45 –Lpath
A.2.45.1 Interactions
Warnings
A.2.46 –llib
A.2.46.1 Interactions
Warnings
See also
A.2.47 –libmieee
A.2.48 –libmil
A.2.49 -library=l[,l...]
A.2.49.1 Values
Defaults
Examples
Interactions
Warnings
See also
A.2.50 -m32|-m64
A.2.51 -mc
A.2.52 –migration
A.2.53 –misalign
A.2.53.1 Interactions
Warnings
A.2.54 -mr[,string]
A.2.54.1 Interactions
A.2.55 –mt
A.2.55.1 Warnings
See also
A.2.56 –native
A.2.57 –noex
A.2.58 –nofstore
A.2.58.1 See also
A.2.59 –nolib
A.2.60 –nolibmil
A.2.61 –noqueue
A.2.62 –norunpath
A.2.62.1 Interactions
A.2.63 –O
A.2.64 –Olevel
A.2.65 –o filename
A.2.65.1 Interactions
Warnings
A.2.66 +p
A.2.66.1 Defaults
Interactions
A.2.67 –P
A.2.67.1 See also
A.2.68 –p
A.2.69 –pentium
A.2.70 –pg
A.2.71 -PIC
A.2.72 –pic
A.2.73 –pta
A.2.74 –ptipath
A.2.74.1 Interactions
See also
A.2.75 –pto
A.2.76 –ptr
A.2.76.1 Warnings
See also
A.2.77 –ptv
A.2.78 –Qoption phase option[,option…]
A.2.78.1 Values
Examples
Warnings
A.2.79 –qoption phase option
A.2.80 –qp
A.2.81 –Qproduce sourcetype
A.2.82 –qproduce sourcetype
A.2.83 –Rpathname[:pathname…]
A.2.83.1 Defaults
Interactions
See also
A.2.84 –readme
A.2.85 –S
A.2.86 –s
A.2.87 –sb
A.2.88 –sbfast
A.2.89 -staticlib=l[,l…]
A.2.89.1 Values
Defaults
Examples
Interactions
Warnings
See also
A.2.90 -sync_stdio=[yes|no]
A.2.90.1 Defaults:
Examples:
Warnings:
A.2.91 –temp=path
A.2.91.1 See also
A.2.92 –template=opt[,opt…]
A.2.92.1 Values
Defaults
Examples
See also
A.2.93 –time
A.2.94 –Uname
A.2.94.1 Examples
Interactions
See also
A.2.95 –unroll=n
A.2.96 –V
A.2.97 –v
A.2.98 –vdelx
A.2.98.1 Default
Warnings
A.2.99 –verbose=v[,v…]
A.2.99.1 Values
Defaults
Interactions
A.2.100 +w
A.2.100.1 Defaults
Interactions
See also
A.2.101 +w2
A.2.101.1 Warnings
See also
A.2.102 –w
A.2.102.1 See also
A.2.103 –Xm
A.2.104 –xa
A.2.104.1 Interactions
Warnings
See also
A.2.105 -xalias_level[=n]
A.2.105.1 Defaults
Interactions
Warning
A.2.106 –xar
A.2.106.1 Values
Examples
Warnings
See also
A.2.107 –xarch=isa
A.2.107.1 -xarch Flags for SPARC
-xarch Flags for x86
Special x86 Notes
Binary Compatibility Verification
The SPARC Default
The x86 Default
Interactions
Warnings
A.2.108 -xautopar
A.2.108.1 See Also
A.2.109 -xbinopt={prepare|off}
A.2.109.1 Defaults
Interactions
A.2.110 -xbuiltin[={%all|%none}]
A.2.110.1 Defaults
Interactions
Examples
A.2.111 –xcache=c
A.2.111.1 Values
Defaults
Examples
See also
A.2.112 -xcg[89|92]
A.2.113 -xchar[=o]
A.2.113.1 Values
Defaults
Interactions
Warnings
A.2.114 -xcheck[=i]
A.2.114.1 Values
Defaults
A.2.115 -xchip=c
A.2.115.1 Values
Defaults
A.2.116 –xcode=a
A.2.116.1 Values
Defaults
Warnings
A.2.117 -xcrossfile[=n]
A.2.117.1 Values
Defaults
Interactions
Warnings
See Also
A.2.118 -xdebugformat=[stabs|dwarf]
A.2.119 -xdepend=[yes|no]
A.2.120 -xdumpmacros[=value[,value...]]
A.2.120.1 Values
Defaults
Examples
See Also
A.2.121 -xe
A.2.121.1 See Also
A.2.122 -xF[=v[,v...]]
A.2.122.1 Values
Defaults
Interactions
See also
A.2.123 –xhelp=flags
A.2.124 –xhelp=readme
A.2.125 -xhwcprof
A.2.126 -xia
A.2.126.1 Expansions
Interactions
Warnings
See also
A.2.127 -xinline[=func_spec[,func_spec...]]
A.2.127.1 Values
Defaults
Examples
Interactions
Warnings
See Also
A.2.128 -xinstrument=[no%]datarace
A.2.129 -xipo[={0|1|2}]
A.2.129.1 Values
Defaults
Examples
Interactions
Warnings
A.2.129.2 When Not To Use -xipo=2 Interprocedural Analysis
See Also
A.2.130 -xipo_archive=[a]
A.2.131 -xjobs=n
A.2.131.1 Values
Defaults
Examples
A.2.132 -xlang=language[,language]
A.2.132.1 Values
Interactions
Warnings
See also
A.2.133 -xldscope={v}
A.2.133.1 Values
Defaults
Warning
See Also
A.2.134 –xlibmieee
A.2.134.1 See also
A.2.135 –xlibmil
A.2.135.1 Interactions
See also
A.2.136 –xlibmopt
A.2.136.1 Interactions
See also
A.2.137 –xlic_lib=sunperf
A.2.138 –xlicinfo
A.2.139 -xlinkopt[=level]
A.2.139.1 Values
Defaults
Interactions
Warnings
A.2.140 –xM
A.2.140.1 Examples
Interactions
See also
A.2.141 -xM1
A.2.142 -xMD
A.2.143 -xMF
A.2.144 -xMMD
A.2.145 –xMerge
A.2.145.1 See also
A.2.146 -xmaxopt[=v]
A.2.147 -xmemalign=ab
A.2.147.1 Values
Defaults
Examples
A.2.148 -xmodel=[a]
A.2.149 –xnolib
A.2.149.1 Examples
Interactions
Warnings
See also
A.2.150 –xnolibmil
A.2.151 –xnolibmopt
A.2.151.1 Examples
A.2.152 -xnorunpath
A.2.153 -xOlevel
A.2.153.1 Values
Interactions
Defaults
Warnings
See also
A.2.154 -xopenmp[=i]
A.2.154.1 Values
Defaults
Interactions
Warnings
See also
A.2.155 -xpagesize=n
A.2.155.1 Values
Defaults
Expansions
Warnings
See Also
A.2.156 -xpagesize_heap=n
A.2.156.1 Values
Defaults
Warnings
See Also
A.2.157 -xpagesize_stack=n
A.2.157.1 Values
Defaults
Warnings
See Also
A.2.158 -xpch=v
A.2.158.1 Creating a Precompiled-Header File
Using A Precompiled-Header File
How to Modify make Files
A.2.159 -xpchstop=file
A.2.159.1 See also
A.2.160 –xpg
A.2.160.1 Warnings
See also
A.2.161 -xport64[=(v)]
A.2.161.1 Values
Defaults
Examples
Checking for the Truncation of 64-bit Values
Checking for Sign Extension
Checking for Changes to Packing of Bitfields
Warnings
See Also
A.2.162 -xprefetch[=a[,a...]]
A.2.162.1 Defaults
Interactions
Warnings
A.2.163 -xprefetch_auto_type=a
A.2.164 -xprefetch_level[=i]
A.2.164.1 Values
Defaults
Interactions
A.2.165 -xprofile=p
A.2.165.1 Values
Interactions
Warnings
See also
A.2.166 -xprofile_ircache[=path]
A.2.167 -xprofile_pathmap
A.2.168 –xregs=r[,r...]
A.2.168.1 Values
Defaults
Examples
See also
A.2.169 -xrestrict[=f]
A.2.169.1 Restricted Pointers
A.2.170 –xs
A.2.171 –xsafe=mem
A.2.171.1 Interactions
A.2.171.2 Warnings
A.2.172 –xsb
A.2.173 –xsbfast
A.2.174 –xspace
A.2.175 –xtarget=t
A.2.175.1 -xtargetValues By Platform
-xtarget Values on SPARC Platforms
-xtarget Values on x86 Platforms
Defaults
Expansions
Examples
Interactions
Warnings
A.2.176 -xthreadvar[=o]
A.2.176.1 Values
Defaults
Interactions
Warnings
See Also
A.2.177 –xtime
A.2.178 -xtrigraphs[={yes|no}]
A.2.178.1 Values
Defaults
Examples
See also
A.2.179 –xunroll=n
A.2.179.1 Values
A.2.180 -xustr={ascii_utf16_ushort|no}
A.2.180.1 Values
Defaults
Example
Warnings
A.2.181 -xvector[=a]
A.2.181.1 Defaults
Interactions
A.2.182 -xvis[={yes|no}]
A.2.182.1 Defaults
See Also
A.2.183 –xwe
A.2.184 -Yc,path
A.2.184.1 Values
Interactions
See also
A.2.185 -z[ ]arg
Appendix B Pragmas
B.1 Pragma Forms
B.1.1 Overloaded Functions as Pragma Arguments
B.2 Pragma Reference
B.2.1 #pragma align
B.2.2 #pragma does_not_read_global_data
B.2.3 #pragma does_not_return
B.2.4 #pragma does_not_write_global_data
B.2.5 #pragma dumpmacros
B.2.6 #pragma end_dumpmacros
B.2.7 #pragma fini
B.2.8 #pragma hdrstop
B.2.9 #pragma ident
B.2.10 #pragma init
B.2.11 #pragma no_side_effect
B.2.12 #pragma opt
B.2.13 #pragma pack(n)
B.2.14 #pragma rarely_called
B.2.15 #pragma returns_new_memory
B.2.16 #pragma unknown_control_flow
B.2.17 #pragma weak
B.2.17.1 #pragma weak name
#pragma weak name1 = name2
Overloading Functions
Glossary
© 2010, Oracle Corporation and/or its affiliates