1 // Predefined symbols and macros -*- C++ -*-
3 // Copyright (C) 1997-2016 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
25 /** @file bits/c++config.h
26 * This is an internal header file, included by other library headers.
27 * Do not attempt to use it directly. @headername{iosfwd}
30 #ifndef _GLIBCXX_CXX_CONFIG_H
31 #define _GLIBCXX_CXX_CONFIG_H 1
33 // The current version of the C++ library in compressed ISO date format.
36 // Macros for various attributes.
41 // _GLIBCXX_VISIBILITY
43 # define _GLIBCXX_PURE __attribute__ ((__pure__))
46 #ifndef _GLIBCXX_CONST
47 # define _GLIBCXX_CONST __attribute__ ((__const__))
50 #ifndef _GLIBCXX_NORETURN
51 # define _GLIBCXX_NORETURN __attribute__ ((__noreturn__))
55 #ifndef _GLIBCXX_NOTHROW
57 # define _GLIBCXX_NOTHROW __attribute__((__nothrow__))
61 // Macros for visibility attributes.
62 // _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
63 // _GLIBCXX_VISIBILITY
64 #define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
66 #if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
67 # define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V)))
69 // If this is not supplied by the OS-specific or CPU-specific
70 // headers included below, it will be defined to an empty default.
71 # define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V)
74 // Macros for deprecated attributes.
75 // _GLIBCXX_USE_DEPRECATED
76 // _GLIBCXX_DEPRECATED
77 #ifndef _GLIBCXX_USE_DEPRECATED
78 # define _GLIBCXX_USE_DEPRECATED 1
81 #if defined(__DEPRECATED) && (__cplusplus >= 201103L)
82 # define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__))
84 # define _GLIBCXX_DEPRECATED
87 // Macros for ABI tag attributes.
88 #ifndef _GLIBCXX_ABI_TAG_CXX11
89 # define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11")))
95 // Macro for constexpr, to support in mixed 03/0x mode.
96 #ifndef _GLIBCXX_CONSTEXPR
97 # if __cplusplus >= 201103L
98 # define _GLIBCXX_CONSTEXPR constexpr
99 # define _GLIBCXX_USE_CONSTEXPR constexpr
101 # define _GLIBCXX_CONSTEXPR
102 # define _GLIBCXX_USE_CONSTEXPR const
106 #ifndef _GLIBCXX14_CONSTEXPR
107 # if __cplusplus >= 201402L
108 # define _GLIBCXX14_CONSTEXPR constexpr
110 # define _GLIBCXX14_CONSTEXPR
114 // Macro for noexcept, to support in mixed 03/0x mode.
115 #ifndef _GLIBCXX_NOEXCEPT
116 # if __cplusplus >= 201103L
117 # define _GLIBCXX_NOEXCEPT noexcept
118 # define _GLIBCXX_NOEXCEPT_IF(_COND) noexcept(_COND)
119 # define _GLIBCXX_USE_NOEXCEPT noexcept
120 # define _GLIBCXX_THROW(_EXC)
122 # define _GLIBCXX_NOEXCEPT
123 # define _GLIBCXX_NOEXCEPT_IF(_COND)
124 # define _GLIBCXX_USE_NOEXCEPT throw()
125 # define _GLIBCXX_THROW(_EXC) throw(_EXC)
129 #ifndef _GLIBCXX_NOTHROW
130 # define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT
133 #ifndef _GLIBCXX_THROW_OR_ABORT
134 # if __cpp_exceptions
135 # define _GLIBCXX_THROW_OR_ABORT(_EXC) (throw (_EXC))
137 # define _GLIBCXX_THROW_OR_ABORT(_EXC) (__builtin_abort())
141 // Macro for extern template, ie controlling template linkage via use
142 // of extern keyword on template declaration. As documented in the g++
143 // manual, it inhibits all implicit instantiations and is used
144 // throughout the library to avoid multiple weak definitions for
145 // required types that are already explicitly instantiated in the
146 // library binary. This substantially reduces the binary size of
147 // resulting executables.
148 // Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern
149 // templates only in basic_string, thus activating its debug-mode
150 // checks even at -O0.
151 #define _GLIBCXX_EXTERN_TEMPLATE
154 Outline of libstdc++ namespaces.
158 namespace __debug { }
159 namespace __parallel { }
160 namespace __profile { }
161 namespace __cxx1998 { }
163 namespace __detail { }
165 namespace rel_ops { }
169 namespace placeholders { }
170 namespace regex_constants { }
171 namespace __detail { }
176 namespace decimal { }
179 namespace placeholders { }
180 namespace regex_constants { }
181 namespace this_thread { }
183 namespace experimental { }
190 namespace __detail { }
193 For full details see:
194 http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html
198 typedef __SIZE_TYPE__ size_t;
199 typedef __PTRDIFF_TYPE__ ptrdiff_t;
201 #if __cplusplus >= 201103L
202 typedef decltype(nullptr) nullptr_t;
206 #define _GLIBCXX_USE_DUAL_ABI
208 #if ! _GLIBCXX_USE_DUAL_ABI
209 // Ignore any pre-defined value of _GLIBCXX_USE_CXX11_ABI
210 # undef _GLIBCXX_USE_CXX11_ABI
213 #ifndef _GLIBCXX_USE_CXX11_ABI
214 #define _GLIBCXX_USE_CXX11_ABI
217 #if _GLIBCXX_USE_CXX11_ABI
220 inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
224 inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
226 # define _GLIBCXX_NAMESPACE_CXX11 __cxx11::
227 # define _GLIBCXX_BEGIN_NAMESPACE_CXX11 namespace __cxx11 {
228 # define _GLIBCXX_END_NAMESPACE_CXX11 }
229 # define _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_ABI_TAG_CXX11
231 # define _GLIBCXX_NAMESPACE_CXX11
232 # define _GLIBCXX_BEGIN_NAMESPACE_CXX11
233 # define _GLIBCXX_END_NAMESPACE_CXX11
234 # define _GLIBCXX_DEFAULT_ABI_TAG
238 // Defined if inline namespaces are used for versioning.
239 #define _GLIBCXX_INLINE_VERSION
241 // Inline namespace for symbol versioning.
242 #if _GLIBCXX_INLINE_VERSION
246 inline namespace __7 { }
248 namespace rel_ops { inline namespace __7 { } }
252 inline namespace __7 { }
253 namespace placeholders { inline namespace __7 { } }
254 namespace regex_constants { inline namespace __7 { } }
255 namespace __detail { inline namespace __7 { } }
259 { inline namespace __7 { } }
261 namespace decimal { inline namespace __7 { } }
263 namespace chrono { inline namespace __7 { } }
264 namespace placeholders { inline namespace __7 { } }
265 namespace regex_constants { inline namespace __7 { } }
266 namespace this_thread { inline namespace __7 { } }
268 namespace experimental { inline namespace __7 { } }
270 namespace __detail { inline namespace __7 { } }
275 inline namespace __7 { }
276 namespace __detail { inline namespace __7 { } }
278 # define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __7 {
279 # define _GLIBCXX_END_NAMESPACE_VERSION }
281 # define _GLIBCXX_BEGIN_NAMESPACE_VERSION
282 # define _GLIBCXX_END_NAMESPACE_VERSION
286 // Inline namespaces for special modes: debug, parallel, profile.
287 #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) \
288 || defined(_GLIBCXX_PROFILE)
291 // Non-inline namespace for components replaced by alternates in active mode.
294 # if _GLIBCXX_INLINE_VERSION
295 inline namespace __7 { }
298 # if _GLIBCXX_USE_CXX11_ABI
299 inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
303 // Inline namespace for debug mode.
304 # ifdef _GLIBCXX_DEBUG
305 inline namespace __debug { }
308 // Inline namespaces for parallel mode.
309 # ifdef _GLIBCXX_PARALLEL
310 inline namespace __parallel { }
313 // Inline namespaces for profile mode
314 # ifdef _GLIBCXX_PROFILE
315 inline namespace __profile { }
319 // Check for invalid usage and unsupported mixed-mode use.
320 # if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL)
321 # error illegal use of multiple inlined namespaces
323 # if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_DEBUG)
324 # error illegal use of multiple inlined namespaces
326 # if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_PARALLEL)
327 # error illegal use of multiple inlined namespaces
330 // Check for invalid use due to lack for weak symbols.
331 # if __NO_INLINE__ && !__GXX_WEAK__
332 # warning currently using inlined namespace mode which may fail \
333 without inlining due to lack of weak symbols
337 // Macros for namespace scope. Either namespace std:: or the name
338 // of some nested namespace within it corresponding to the active mode.
342 // Macros for opening/closing conditional namespaces.
343 // _GLIBCXX_BEGIN_NAMESPACE_ALGO
344 // _GLIBCXX_END_NAMESPACE_ALGO
345 // _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
346 // _GLIBCXX_END_NAMESPACE_CONTAINER
347 #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE)
348 # define _GLIBCXX_STD_C __cxx1998
349 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \
350 namespace _GLIBCXX_STD_C { _GLIBCXX_BEGIN_NAMESPACE_VERSION
351 # define _GLIBCXX_END_NAMESPACE_CONTAINER \
352 _GLIBCXX_END_NAMESPACE_VERSION }
355 #ifdef _GLIBCXX_PARALLEL
356 # define _GLIBCXX_STD_A __cxx1998
357 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO \
358 namespace _GLIBCXX_STD_A { _GLIBCXX_BEGIN_NAMESPACE_VERSION
359 # define _GLIBCXX_END_NAMESPACE_ALGO \
360 _GLIBCXX_END_NAMESPACE_VERSION }
363 #ifndef _GLIBCXX_STD_A
364 # define _GLIBCXX_STD_A std
367 #ifndef _GLIBCXX_STD_C
368 # define _GLIBCXX_STD_C std
371 #ifndef _GLIBCXX_BEGIN_NAMESPACE_ALGO
372 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO
375 #ifndef _GLIBCXX_END_NAMESPACE_ALGO
376 # define _GLIBCXX_END_NAMESPACE_ALGO
379 #ifndef _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
380 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
383 #ifndef _GLIBCXX_END_NAMESPACE_CONTAINER
384 # define _GLIBCXX_END_NAMESPACE_CONTAINER
387 // GLIBCXX_ABI Deprecated
388 // Define if compatibility should be provided for -mlong-double-64.
389 #undef _GLIBCXX_LONG_DOUBLE_COMPAT
391 // Inline namespace for long double 128 mode.
392 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
395 inline namespace __gnu_cxx_ldbl128 { }
397 # define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128::
398 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 {
399 # define _GLIBCXX_END_NAMESPACE_LDBL }
401 # define _GLIBCXX_NAMESPACE_LDBL
402 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL
403 # define _GLIBCXX_END_NAMESPACE_LDBL
405 #if _GLIBCXX_USE_CXX11_ABI
406 # define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_CXX11
407 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_CXX11
408 # define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_CXX11
410 # define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_LDBL
411 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_LDBL
412 # define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_LDBL
415 // Debug Mode implies checking assertions.
416 #ifdef _GLIBCXX_DEBUG
417 # define _GLIBCXX_ASSERTIONS
420 // Disable std::string explicit instantiation declarations in order to assert.
421 #ifdef _GLIBCXX_ASSERTIONS
422 # undef _GLIBCXX_EXTERN_TEMPLATE
423 # define _GLIBCXX_EXTERN_TEMPLATE -1
427 #if !defined(_GLIBCXX_ASSERTIONS) && !defined(_GLIBCXX_PARALLEL)
428 # define __glibcxx_assert(_Condition)
432 // Avoid the use of assert, because we're trying to keep the <cassert>
433 // include out of the mix.
435 __replacement_assert(const char* __file, int __line,
436 const char* __function, const char* __condition)
438 __builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line,
439 __function, __condition);
443 #define __glibcxx_assert(_Condition) \
446 if (! (_Condition)) \
447 std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
452 // Macros for race detectors.
453 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and
454 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain
455 // atomic (lock-free) synchronization to race detectors:
456 // the race detector will infer a happens-before arc from the former to the
457 // latter when they share the same argument pointer.
459 // The most frequent use case for these macros (and the only case in the
460 // current implementation of the library) is atomic reference counting:
461 // void _M_remove_reference()
463 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
464 // if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0)
466 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
470 // The annotations in this example tell the race detector that all memory
471 // accesses occurred when the refcount was positive do not race with
472 // memory accesses which occurred after the refcount became zero.
473 #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE
474 # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A)
476 #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER
477 # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A)
480 // Macros for C linkage: define extern "C" linkage only when using C++.
481 # define _GLIBCXX_BEGIN_EXTERN_C extern "C" {
482 # define _GLIBCXX_END_EXTERN_C }
484 #define _GLIBCXX_USE_ALLOCATOR_NEW
486 #else // !__cplusplus
487 # define _GLIBCXX_BEGIN_EXTERN_C
488 # define _GLIBCXX_END_EXTERN_C
494 // Pick up any OS-specific definitions.
495 #include <bits/os_defines.h>
497 // Pick up any CPU-specific definitions.
498 #include <bits/cpu_defines.h>
500 // If platform uses neither visibility nor psuedo-visibility,
501 // specify empty default for namespace annotation macros.
502 #ifndef _GLIBCXX_PSEUDO_VISIBILITY
503 # define _GLIBCXX_PSEUDO_VISIBILITY(V)
506 // Certain function definitions that are meant to be overridable from
507 // user code are decorated with this macro. For some targets, this
508 // macro causes these definitions to be weak.
509 #ifndef _GLIBCXX_WEAK_DEFINITION
510 # define _GLIBCXX_WEAK_DEFINITION
513 // By default, we assume that __GXX_WEAK__ also means that there is support
514 // for declaring functions as weak while not defining such functions. This
515 // allows for referring to functions provided by other libraries (e.g.,
516 // libitm) without depending on them if the respective features are not used.
517 #ifndef _GLIBCXX_USE_WEAK_REF
518 # define _GLIBCXX_USE_WEAK_REF __GXX_WEAK__
521 // Conditionally enable annotations for the Transactional Memory TS on C++11.
522 // Most of the following conditions are due to limitations in the current
524 #if __cplusplus >= 201103L && _GLIBCXX_USE_CXX11_ABI \
525 && _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201505L \
526 && !_GLIBCXX_FULLY_DYNAMIC_STRING && _GLIBCXX_USE_WEAK_REF \
527 && _GLIBCXX_USE_ALLOCATOR_NEW
528 #define _GLIBCXX_TXN_SAFE transaction_safe
529 #define _GLIBCXX_TXN_SAFE_DYN transaction_safe_dynamic
531 #define _GLIBCXX_TXN_SAFE
532 #define _GLIBCXX_TXN_SAFE_DYN
536 // The remainder of the prewritten config is automatic; all the
537 // user hooks are listed above.
539 // Create a boolean flag to be used to determine if --fast-math is set.
541 # define _GLIBCXX_FAST_MATH 1
543 # define _GLIBCXX_FAST_MATH 0
546 // This marks string literals in header files to be extracted for eventual
547 // translation. It is primarily used for messages in thrown exceptions; see
548 // src/functexcept.cc. We use __N because the more traditional _N is used
549 // for something else under certain OSes (see BADNAMES).
550 #define __N(msgid) (msgid)
552 // For example, <windows.h> is known to #define min and max as macros...
556 // N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally
557 // so they should be tested with #if not with #ifdef.
558 #if __cplusplus >= 201103L
559 # ifndef _GLIBCXX_USE_C99_MATH
560 # define _GLIBCXX_USE_C99_MATH _GLIBCXX11_USE_C99_MATH
562 # ifndef _GLIBCXX_USE_C99_COMPLEX
563 # define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX11_USE_C99_COMPLEX
565 # ifndef _GLIBCXX_USE_C99_STDIO
566 # define _GLIBCXX_USE_C99_STDIO _GLIBCXX11_USE_C99_STDIO
568 # ifndef _GLIBCXX_USE_C99_STDLIB
569 # define _GLIBCXX_USE_C99_STDLIB _GLIBCXX11_USE_C99_STDLIB
571 # ifndef _GLIBCXX_USE_C99_WCHAR
572 # define _GLIBCXX_USE_C99_WCHAR _GLIBCXX11_USE_C99_WCHAR
575 # ifndef _GLIBCXX_USE_C99_MATH
576 # define _GLIBCXX_USE_C99_MATH _GLIBCXX98_USE_C99_MATH
578 # ifndef _GLIBCXX_USE_C99_COMPLEX
579 # define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX98_USE_C99_COMPLEX
581 # ifndef _GLIBCXX_USE_C99_STDIO
582 # define _GLIBCXX_USE_C99_STDIO _GLIBCXX98_USE_C99_STDIO
584 # ifndef _GLIBCXX_USE_C99_STDLIB
585 # define _GLIBCXX_USE_C99_STDLIB _GLIBCXX98_USE_C99_STDLIB
587 # ifndef _GLIBCXX_USE_C99_WCHAR
588 # define _GLIBCXX_USE_C99_WCHAR _GLIBCXX98_USE_C99_WCHAR
592 // End of prewritten config; the settings discovered at configure time follow.