JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris Studio 12.3: C++ User's Guide     Oracle Solaris Studio 12.3 Information Library
search filter icon
search icon

Document Information


Part I C++ Compiler

1.  The C++ Compiler

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 64-Bit Memory Model

2.4.5 Compiler Command-Line Diagnostics

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 Warnings and Errors

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 Using the strip Command with C++ Objects

2.8 Simplifying Commands

2.8.1 Using Aliases Within the C Shell

2.8.2 Using CCFLAGS to Specify Compile Options

2.8.3 Using make Using CCFLAGS Within make

3.  Using the C++ Compiler Options

Part II Writing C++ Programs

4.  Language Extensions

5.  Program Organization

6.  Creating and Using Templates

7.  Compiling Templates

8.  Exception Handling

9.  Improving Program Performance

10.  Building Multithreaded Programs

Part III Libraries

11.  Using Libraries

12.  Using the C++ Standard Library

13.  Using the Classic iostream Library

14.  Building Libraries

Part IV Appendixes

A.  C++ Compiler Options

B.  Pragmas



2.2 Invoking the Compiler

The remainder of this chapter discusses the conventions used by the CC command, compiler source line directives, and other issues concerning the use of the compiler.

2.2.1 Command Syntax

The general syntax of a compiler command line is as follows:

CC [options] [source-files] [object-files] [libraries]

An option is an option keyword prefixed by either a dash () or a plus sign (+). Some options take arguments.

In general, the processing of the compiler options is from left to right, allowing selective overriding of macro options (options that include other options). In most cases, if you specify the same option more than once, the rightmost assignment overrides and there is no accumulation. Note the following exceptions:

Source files, object files, and libraries are compiled and linked in the order in which they appear on the command line.

In the following example, CC is used to compile two source files (growth.C and fft.C) to produce an executable file named growth with runtime debugging enabled:

example% CC -g -o growth growth.C fft.C

2.2.2 File Name Conventions

The suffix attached to a file name appearing on the command line determines how the compiler processes the file. A file name with a suffix other than those listed in the following table, or without a suffix, is passed to the linker.

Table 2-1 File Name Suffixes Recognized by the C++ Compiler

Compile as C++ source files, put object files in current directory; default name of object file is that of the source but with an .o suffix.
Same action as .c suffix.
Same action as .c suffix.
Same action as .c suffix.
Same action as .c suffix.
Same action as .c suffix.
Preprocessor output file treated as C++ source file. Same action as .c suffix.
Assemble source files using the assembler.
Assemble source files using both the C language preprocessor and the assembler.
Inline expansion
Process assembly inline-template files for inline expansion. The compiler will use templates to expand inline calls to selected routines. (Inline-template files are special assembler files. See the inline(1) man page.)
Object files
Pass object files through to the linker.
Static (archive) library
Pass object library names to the linker.


Dynamic (shared) library
Pass names of shared objects to the linker.

2.2.3 Using Multiple Source Files

The C++ compiler accepts multiple source files on the command line. A single source file compiled by the compiler, together with any files that it directly or indirectly supports, is referred to as a compilation unit. C++ treats each source as a separate compilation unit.