This chapter provides information about the following:
This section provides a brief overview of the new C compiler features and functionality introduced in the Sun Studio 12 C++ 5.9 Compiler release. For specific explanations, follow the cross references provided for each item.
The C compiler is now available on the following Linux distributions (x86 and x64)
SuSE Linux Enterprise Server 9 with Service Pack 3 (or later).
Red Hat Enterprise Linux 4.
Other Linux distributions based on the 2.6 kernel though these are not officially supported.
New -m32|-m64 options to determine the memory model.
New flags for -xarch replace obsolete flags.
New values for -xtarget and -xchip provide code generation for the UltraSPARC T2 and SPARC64vi processors.
New flag -fma=fused to enable generation of fused multiply-add instructions on processors that support them.
Explicit prefetch macros accepted on x86 platforms as well as SPARC platforms. (-xprefetch=explicit)
The way to specify compilation of a 32-bit or 64-bit binary has changed in this release. The A.2.107 –xarch=isaoption no longer carries an implicit memory model, 32-bit ILP32 or 64-bit LP64, with each definition, and is now used only to specify the instruction set of the target processor.
Use the new A.2.50 -m32|-m64 options to specify the memory model of the target compilation.
The ILP32 model specifies that C-language int, long, and pointer data types are all 32-bits wide. The LP64 model specifies that long and pointer data types are all 64-bits wide. The Solaris and Linux OS also support large files and large arrays under the LP64 memory model.
When you compile with -m64, the resulting executable works only on 64-bit UltraSPARC(R) or x86 processors under Solaris OS or Linux OS running a 64-bit kernel. Compilation, linking, and execution of 64-bit objects can only take place in a Solaris or Linux OS that supports 64-bit execution.
There are some important issues to be aware of when compiling for x86 Solaris platforms.
The legacy Sun-style parallelization pragmas are not available on x86. Use OpenMP instead. See the Sun Studio 12: OpenMP API User’s Guide for information on converting legacy parallelization directives to OpenMP.
Programs compiled with -xarch set to sse, sse2, sse2a, or sse3 must be run only on platforms that provide these extensions and features.
Solaris OS releases starting with Solaris 9 4/04 are SSE/SSE2-enabled on Pentium 4-compatible platforms. Earlier versions of Solaris OS are not SSE/SSE2-enabled. If an instruction set selected by -xarch is not enabled in the running Solaris OS, the compiler will not be able to generate or link code for that instruction set.
If you compile and link in separate steps, always link using the compiler and with same -xarch setting to ensure that the correct startup routine is linked.
Numerical results on x86 might differ from results on SPARC due to the x86 80-bit floating-point registers. To minimize these differences, use the -fstore option or compile with x-arch=sse2 if the hardware supports SSE2.
Numerical results can also differ between Solaris and Linux because the intrinsic math libraries (for example, sin(x)) are not the same.
Starting with Sun Studio 11 and the Solaris 10 OS, program binaries compiled and built using these specialized -xarch hardware flags are verified that they are being run on the appropriate platform.
On systems prior to Solaris 10, no verification is done and it is the user's responsibility to ensure objects built using these flags are deployed on suitable hardware.
Running programs compiled with these -xarch options on platforms that are not enabled with the appropriate features or instruction set extensions could result in segmentation faults or incorrect results occurring without any explicit warning messages.
This warning extends also to programs that employ .il inline assembly language functions or __asm() assembler code that utilize SSE, SSE2, SSE2a, and SSE3 instructions and extensions.
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 SPARCTM platforms, the compiler provides support for the optimization-exploiting features of SPARC V8 and SPARC V9, including the UltraSPARCTM 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.
The C++ compiler’s readme file highlights important information about the compiler, including:
Information discovered after the manuals were printed
New and changed features
Software corrections
Problems and workarounds
Limitations and incompatibilities
Shippable libraries
Standards not implemented
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.
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 |
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.
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 system documentation.