In Oracle Solaris Studio 12.4, the C++ compiler supports C++11, a new language and ABI (Application Binary Interface).
In C++ 11 mode, the CC compiler uses the g++ ABI and a version of the g++ runtime library that is supplied with Oracle Solaris Studio. For this release, version 4.8.2 of the g++ runtime library is used.
An ABI describes the low-level details in the generated object code. Modules that use different ABIs cannot successfully be linked together into a program. This means that you must use C++11 mode on all modules in your program, or none of them.
If you use Oracle Solaris Studio 12.4 C++ as an upgrade to Oracle Solaris Studio 12.3 (C++ 5.12), no changes are needed in scripts or makefiles if you are not using C++11 features. An exception is Rogue Wave Tools.h++ is not available. For more information about features no longer supported, see Features That Have Been Removed in This Release in Oracle Solaris Studio 12.4: Release Notes
To compile in C++11 mode, add the option –std=c++11 to the CC command line. The location on the command line is not important. The option causes the compiler to recognize language features new in C++11, and to use the C++11 version of the standard library (g++ runtime library that is supplied). Except for the options marked as incompatible with –std=c++11, all other command-line options can be used along with C++11, and have their usual effects. The –std=c++11 option must be used consistently on every CC command used in building a library or executable program.
The C++ compiler in this release has the following updated version details.
__SUNPRO_CC = 0x5130
The compiler version macro is strictly greater than all earlier releases, so version comparisons such as __SUNPRO_CC>=0x5100 continue to work.
C++03 with -compat=5.
This is the same default mode as C++ 5.12 in the Oracle Solaris Studio 12.3 release.
Oracle Solaris Studio 12.3 had the following compiler mode options:
This option selects C++03 with the Sun ABI. This is the default.
This option selects C++03 with the g++ ABI, using the gcc headers and libraries provided with the compiler. In Oracle Solaris Studio 12.3, the gcc runtime libraries are installed in /usr/sfw/lib on Oracle Solaris if present. In this release, gcc runtime libraries supplied with the compiler are used instead.
The release adds the option –std=[ c++11 | c++0x | c++03 | sun03] where the option values are defined as follows:
This option selects C++11 with the g++ ABI and uses the g++ 4.8.2 runtime libraries installed as part of Oracle Solaris Studio 12.4.
This option is equivalent to the –std=c++11 option and is provided for GCC compatibility. The C++11 standard was nicknamed C++0x initially.
This option is equivalent to the –compat=g option.
This option is equivalent to –compat=5
-compat=g -compat=5 // OK, -compat=5 is used -std=c++11 -std=c++03 // OK, -std=c++03 is used -std=c++11 -compat=g // always an error -compat=g -std=c++03 // always an error
The option –xustr=ascii_utf16_ushort is not compatible with C++11, and is not allowed.
The option interprets U"ASCII_string" as 16-bit Unicode, but C++11 requires 32-bit Unicode for that syntax.
With –std=x or –compat=g, the following –library=v options are not allowed:
When you need to list libraries to be linked, such as when you are creating a shared library, use the following options in this order when using the –compat=g or –std=x options:
-lstdc++ -lgcc_s -lCrunG3
When creating an executable program using CC, you should not list these libraries, because the CC driver will list them for you.
For information about libraries removed in this release, see Features That Have Been Removed in This Release in Oracle Solaris Studio 12.4: Release Notes .
The following commands could be used for building executable program myprogram from modules main.cc, f1.cc, and f2.cc:
% CC -std=c++11 -m32 -O -c main.cc % CC -std=c++11 -m32 -O -c f1.cc f2.cc % CC -std=c++11 -m32 -O main.o f1.o f2.o -o myprogram
If you have a Makefile that builds a C++ program using older versions of Oracle Solaris Studio, you can convert it to build a C++11 program by adding –std=c++11 to every CC command line (typically in the CCFLAGS and LFLAGS macros), and by removing any incompatible options such as –compat=5 or –library=stlport4. Valid C++ programs usually compile and run unchanged when compiled in C++11 mode. Unfortunately, many real programs depend, sometimes accidentally, on non-standard compiler behavior or extensions. Such code might not compile in C++11 mode.