C H A P T E R  1

The C++ Compiler

This chapter provides a brief conceptual overview of the C++ compiler.


1.1 Standards Conformance

The C++ compiler (CC) supports the ISO International Standard for C++, ISO IS 14882:1998, Programming Language--C++. The readme file that accompanies the current release describes any departures from requirements in the standard.

On SPARCtrademark platforms, the compiler provides support for the optimization-exploiting features of SPARC V8 and SPARC V9, including the UltraSPARCtrademark implementation. These features are defined in the SPARC Architecture Manuals, Version 8 (ISBN 0-13-825001-4), and Version 9 (ISBN 0-13-099227-5), published by Prentice-Hall for SPARC International.

In this document, "Standard" means conforming to the versions of the standards listed above. "Nonstandard" or "Extension" refers to features that go beyond these versions of these standards.

The responsible standards bodies may revise these standards from time to time. The versions of the applicable standards to which the C++ compiler conforms may be revised or replaced, resulting in features in future releases of the Sun C++ compiler that create incompatibilities with earlier releases.


1.2 C++ Readme File

The C++ compiler's readme file highlights important information about the compiler, including:

To view the text version of the C++ readme file, type the following at a command prompt:

example% CC -xhelp=readme

To access the HTML version of the readme, in your Netscape Communicator 4.0 or compatible version browser, open the following file:

/opt/SUNWspro/docs/index.html

(If your C++ compiler-software is not installed in the /opt directory, ask your system administrator for the equivalent path on your system.) Your browser displays an index of HTML documents. To open the readme, find its entry in the index, then click the title.


1.3 Man Pages

Online manual (man) pages provide immediate documentation about a command, function, subroutine, or collection of such things.

You can display a man page by running the command:

example% man topic

Throughout the C++ documentation, man page references appear with the topic name and man section number: CC(1) is accessed with man CC. Other sections, denoted by ieee_flags(3M) for example, are accessed using the -s option on the man command:

example% man -s 3M ieee_flags


1.4 Licensing

The C++ compiler uses network licensing, as described in the Installation Guide.

If you invoke the compiler, and a license is available, the compiler starts. A single license can be used for any number of simultaneous compiles by a single user on a single machine.

To run C++ and the various utilities, several licenses might be required, depending on the package you have purchased.


1.5 New Features of the C++ Compiler

The C++ compiler introduces the following new features:

  • Support for OpenMP in C++ (SPARC)
This release of the C++ compiler implements the OpenMP interface for explicit parallelization including a set of source code directives, run-time library routines, and environment variables with the following new option:
CC -xopenmp[=i]
See Appendix A.2.130 for more information.
  • Type-based alias analysis and optimizations (SPARC)
The C++ compiler now accepts the -xnoalias option which allows it to perform type-based alias analysis and optimizations with the following new option:
CC -xnoalias[=i]
See Appendix A.2.97 for more information.
  • Support for the Native Connector Tool
Use the new -xnativeconnect option when you want to include interface information inside object files and subsequent shared libraries so that the shared library can interface with code written in the Java[tm] programming language (Java code). When you compile with the new -xnativeconnect option, you are providing the maximum, external, visibility of the native code interfaces. The Native Connector Tool (NCT) enables the automatic generation of Java code and Java Native Interface (JNI) code so that C++ shared libraries can be called from Java code. For more information on how to use the NCT, see the Forte Developer online help.
See Appendix A.2.126 for more information.
  • Enhanced interprocedural optimizations (SPARC)
The -xipo option now offers a new level of optimization in which the compiler performs inlining across all source files. With -xipo=2, the compiler performs interprocedural aliasing analysis as well as optimizations of memory allocation and layout to improve cache performance.
See Appendix A.2.115 for more information.
  • Finer control over prefetches
Use the new -xprefetch_level=n option to control the aggressiveness of the automatic insertion of prefetch instructions as determined with -xprefetch=auto. n must be one of 1, 2, or 3. The compiler becomes more aggressive, or in other words, introduces more prefetches with each higher level of -xprefetch_level.
See Appendix A.2.134 for more information.
  • A new check for stack overflows
Compile with the new -xcheck=stkovf option to add a runtime check for stack overflow of the main thread in a singly-threaded program as well as slave-thread stacks in a multithreaded program. If a stack overflow is detected, a SIGSEGV is generated.
See Appendix A.2.104 for more information.
  • Support for the STLport standard library
The C++ compiler now supports STLport's Standard Library implementation version 4.5.2. libCstd is still the default library, but STLport's product is now available as an alternative. This release includes both a static archive called libstlport.a and a dynamic library called libstlport.so.
See Appendix A.2.44 for more information.
  • The +w option is now more widely applicable
The +w option no longer reports that a function is too large to inline and no longer reports that parameters are unused in order to reduce output messages and simplify the use of the +w option in routine builds.
  • Streamlined +w2 option is now more widely applicable
The +w2 option no longer reports the use of implementation-dependent constructs in the system header files in order to simplify the use of the +w2 option in routine builds.
  • Immediate compilation abort with improved #error directive
The previous behavior of the #error directive was to issue a warning and continue compilation. The new behavior, consistent with other compilers, is to issue an error message and immediately halt compilation. The compiler quits and reports the failure.


1.6 C++ Utilities

The following C++ utilities are now incorporated into traditional UNIX® tools and are bundled with the UNIX operating system:

  • lex--Generates programs used in simple lexical analysis of text
  • yacc--Generates a C function to parse the input stream according to syntax
  • prof--Produces an execution profile of modules in a program
  • gprof--Profiles program runtime performance by procedure
  • tcov--Profiles program runtime performance by statement

See Program Performance Analysis Tools and associated man pages for further information on these UNIX tools.


1.7 Native-Language Support

This release of C++ supports the development of applications in languages other than English, including most European languages and Japanese. As a result, you can easily switch your application from one native language to another. This feature is known as internationalization.

In general, the C++ compiler implements internationalization as follows:

  • C++ recognizes ASCII characters from international keyboards (in other words, it has keyboard independence and is 8-bit clean).
  • C++ allows the printing of some messages in the native language.
  • C++ allows native-language characters in comments, strings, and data.
  • C++ supports only Extended UNIX Character (EUC) compliant character sets - a character set in which every null byte in a string is the null character and every byte in the string with the ascii value of '/' is the '/' character.

Variable names cannot be internationalized and must be in the English character set.

You can change your application from one native language to another by setting the locale. For information on this and other native-language support features, see the operating environment documentation.