Chapter 3. Using

Table of Contents

Command Options
Headers
Header Files
Mixing Headers
The C Headers and namespace std
Precompiled Headers
Macros
Dual ABI
Troubleshooting
Namespaces
Available Namespaces
namespace std
Using Namespace Composition
Linking
Almost Nothing
Finding Dynamic or Shared Libraries
Experimental Library Extensions
Concurrency
Prerequisites
Thread Safety
Atomics
IO
Structure
Defaults
Future
Alternatives
Containers
Exceptions
Exception Safety
Exception Neutrality
Doing without
Compatibility
With C
With POSIX thread cancellation
Debugging Support
Using g++
Debug Versions of Library Binary Files
Memory Leak Hunting
Data Race Hunting
Using gdb
Tracking uncaught exceptions
Debug Mode
Compile Time Checking
Profile-based Performance Analysis

Command Options

The set of features available in the GNU C++ library is shaped by several GCC Command Options. Options that impact libstdc++ are enumerated and detailed in the table below.

The standard library conforms to the dialect of C++ specified by the -std option passed to the compiler. By default, g++ is equivalent to g++ -std=gnu++14 since GCC 6, and g++ -std=gnu++98 for older releases.

Table 3.1. C++ Command Options

Option FlagsDescription
-std=c++98 or -std=c++03 Use the 1998 ISO C++ standard plus amendments.
-std=gnu++98 or -std=gnu++03 As directly above, with GNU extensions.
-std=c++11Use the 2011 ISO C++ standard.
-std=gnu++11As directly above, with GNU extensions.
-std=c++14Use the 2014 ISO C++ standard.
-std=gnu++14As directly above, with GNU extensions.
-fexceptionsSee exception-free dialect
-frttiAs above, but RTTI-free dialect.
-pthread or -pthreadsFor ISO C++11 <thread>, <future>, <mutex>, or <condition_variable>.
-latomicLinking to libatomic is required for some uses of ISO C++11 <atomic>.
-lstdc++fsLinking to libstdc++fs is required for use of the Filesystem library extensions in <experimental/filesystem>.
-fopenmpFor parallel mode.