1 // Predefined symbols and macros -*- C++ -*-
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4 // 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // Under Section 7 of GPL version 3, you are granted additional
18 // permissions described in the GCC Runtime Library Exception, version
19 // 3.1, as published by the Free Software Foundation.
21 // You should have received a copy of the GNU General Public License and
22 // a copy of the GCC Runtime Library Exception along with this program;
23 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 // <http://www.gnu.org/licenses/>.
26 /** @file bits/c++config.h
27 * This is an internal header file, included by other library headers.
28 * Do not attempt to use it directly. @headername{iosfwd}
31 #ifndef _GLIBCXX_CXX_CONFIG_H
32 #define _GLIBCXX_CXX_CONFIG_H 1
34 // The current version of the C++ library in compressed ISO date format.
37 // Macros for various attributes.
42 // _GLIBCXX_VISIBILITY
44 # define _GLIBCXX_PURE __attribute__ ((__pure__))
47 #ifndef _GLIBCXX_CONST
48 # define _GLIBCXX_CONST __attribute__ ((__const__))
51 #ifndef _GLIBCXX_NORETURN
52 # define _GLIBCXX_NORETURN __attribute__ ((__noreturn__))
55 #ifndef _GLIBCXX_NOTHROW
57 # define _GLIBCXX_NOTHROW throw()
59 # define _GLIBCXX_NOTHROW __attribute__((__nothrow__))
63 // Macros for visibility attributes.
64 // _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
65 // _GLIBCXX_VISIBILITY
66 #define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
68 #if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
69 # define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V)))
71 // If this is not supplied by the OS-specific or CPU-specific
72 // headers included below, it will be defined to an empty default.
73 # define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V)
76 // Macros for deprecated attributes.
77 // _GLIBCXX_USE_DEPRECATED
78 // _GLIBCXX_DEPRECATED
79 #ifndef _GLIBCXX_USE_DEPRECATED
80 # define _GLIBCXX_USE_DEPRECATED 1
83 #if defined(__DEPRECATED) && defined(__GXX_EXPERIMENTAL_CXX0X__)
84 # define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__))
86 # define _GLIBCXX_DEPRECATED
91 // Macro for constexpr, to support in mixed 03/0x mode.
92 #ifndef _GLIBCXX_CONSTEXPR
93 # ifdef __GXX_EXPERIMENTAL_CXX0X__
94 # define _GLIBCXX_CONSTEXPR constexpr
95 # define _GLIBCXX_USE_CONSTEXPR constexpr
97 # define _GLIBCXX_CONSTEXPR
98 # define _GLIBCXX_USE_CONSTEXPR const
102 // Macro for extern template, ie controling template linkage via use
103 // of extern keyword on template declaration. As documented in the g++
104 // manual, it inhibits all implicit instantiations and is used
105 // throughout the library to avoid multiple weak definitions for
106 // required types that are already explicitly instantiated in the
107 // library binary. This substantially reduces the binary size of
108 // resulting executables.
109 // Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern
110 // templates only in basic_string, thus activating its debug-mode
111 // checks even at -O0.
112 #ifndef _GLIBCXX_EXTERN_TEMPLATE
113 # define _GLIBCXX_EXTERN_TEMPLATE 1
117 Outline of libstdc++ namespaces.
121 namespace __debug { }
122 namespace __parallel { }
123 namespace __profile { }
124 namespace __cxx1998 { }
126 namespace __detail { }
128 namespace rel_ops { }
132 namespace placeholders { }
133 namespace regex_constants { }
134 namespace __detail { }
137 namespace decimal { }
140 namespace placeholders { }
141 namespace regex_constants { }
142 namespace this_thread { }
149 namespace __detail { }
152 For full details see:
153 http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html
157 typedef __SIZE_TYPE__ size_t;
158 typedef __PTRDIFF_TYPE__ ptrdiff_t;
160 #ifdef __GXX_EXPERIMENTAL_CXX0X__
161 typedef decltype(nullptr) nullptr_t;
166 // Defined if inline namespaces are used for versioning.
167 #define _GLIBCXX_INLINE_VERSION
169 // Inline namespace for symbol versioning.
170 #if _GLIBCXX_INLINE_VERSION
173 inline namespace _6 { }
175 namespace __detail { inline namespace _6 { } }
178 namespace rel_ops { inline namespace _6 { } }
182 inline namespace _6 { }
183 namespace placeholders { inline namespace _6 { } }
184 namespace regex_constants { inline namespace _6 { } }
185 namespace __detail { inline namespace _6 { } }
188 namespace decimal { inline namespace _6 { } }
190 namespace chrono { inline namespace _6 { } }
191 namespace placeholders { inline namespace _6 { } }
192 namespace regex_constants { inline namespace _6 { } }
193 namespace this_thread { inline namespace _6 { } }
198 inline namespace _6 { }
199 namespace __detail { inline namespace _6 { } }
201 # define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace _6 {
202 # define _GLIBCXX_END_NAMESPACE_VERSION }
204 # define _GLIBCXX_BEGIN_NAMESPACE_VERSION
205 # define _GLIBCXX_END_NAMESPACE_VERSION
209 // Inline namespaces for special modes: debug, parallel, profile.
210 #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) \
211 || defined(_GLIBCXX_PROFILE)
214 // Non-inline namespace for components replaced by alternates in active mode.
217 #if _GLIBCXX_INLINE_VERSION
218 inline namespace _6 { }
222 // Inline namespace for debug mode.
223 # ifdef _GLIBCXX_DEBUG
224 inline namespace __debug { }
227 // Inline namespaces for parallel mode.
228 # ifdef _GLIBCXX_PARALLEL
229 inline namespace __parallel { }
232 // Inline namespaces for profile mode
233 # ifdef _GLIBCXX_PROFILE
234 inline namespace __profile { }
238 // Check for invalid usage and unsupported mixed-mode use.
239 # if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL)
240 # error illegal use of multiple inlined namespaces
242 # if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_DEBUG)
243 # error illegal use of multiple inlined namespaces
245 # if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_PARALLEL)
246 # error illegal use of multiple inlined namespaces
249 // Check for invalid use due to lack for weak symbols.
250 # if __NO_INLINE__ && !__GXX_WEAK__
251 # warning currently using inlined namespace mode which may fail \
252 without inlining due to lack of weak symbols
256 // Macros for namespace scope. Either namespace std:: or the name
257 // of some nested namespace within it corresponding to the active mode.
261 // Macros for opening/closing conditional namespaces.
262 // _GLIBCXX_BEGIN_NAMESPACE_ALGO
263 // _GLIBCXX_END_NAMESPACE_ALGO
264 // _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
265 // _GLIBCXX_END_NAMESPACE_CONTAINER
266 #if defined(_GLIBCXX_DEBUG) or defined(_GLIBCXX_PROFILE)
267 # define _GLIBCXX_STD_C __cxx1998
268 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \
269 namespace _GLIBCXX_STD_C { _GLIBCXX_BEGIN_NAMESPACE_VERSION
270 # define _GLIBCXX_END_NAMESPACE_CONTAINER \
271 } _GLIBCXX_END_NAMESPACE_VERSION
272 # undef _GLIBCXX_EXTERN_TEMPLATE
273 # define _GLIBCXX_EXTERN_TEMPLATE -1
276 #ifdef _GLIBCXX_PARALLEL
277 # define _GLIBCXX_STD_A __cxx1998
278 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO \
279 namespace _GLIBCXX_STD_A { _GLIBCXX_BEGIN_NAMESPACE_VERSION
280 # define _GLIBCXX_END_NAMESPACE_ALGO \
281 } _GLIBCXX_END_NAMESPACE_VERSION
284 #ifndef _GLIBCXX_STD_A
285 # define _GLIBCXX_STD_A std
288 #ifndef _GLIBCXX_STD_C
289 # define _GLIBCXX_STD_C std
292 #ifndef _GLIBCXX_BEGIN_NAMESPACE_ALGO
293 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO
296 #ifndef _GLIBCXX_END_NAMESPACE_ALGO
297 # define _GLIBCXX_END_NAMESPACE_ALGO
300 #ifndef _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
301 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
304 #ifndef _GLIBCXX_END_NAMESPACE_CONTAINER
305 # define _GLIBCXX_END_NAMESPACE_CONTAINER
308 // GLIBCXX_ABI Deprecated
309 // Define if compatibility should be provided for -mlong-double-64.
310 #undef _GLIBCXX_LONG_DOUBLE_COMPAT
312 // Inline namespace for long double 128 mode.
313 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
316 inline namespace __gnu_cxx_ldbl128 { }
318 # define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128::
319 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 {
320 # define _GLIBCXX_END_NAMESPACE_LDBL }
322 # define _GLIBCXX_NAMESPACE_LDBL
323 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL
324 # define _GLIBCXX_END_NAMESPACE_LDBL
328 #if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PARALLEL)
329 # define __glibcxx_assert(_Condition)
333 // Avoid the use of assert, because we're trying to keep the <cassert>
334 // include out of the mix.
336 __replacement_assert(const char* __file, int __line,
337 const char* __function, const char* __condition)
339 __builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line,
340 __function, __condition);
344 #define __glibcxx_assert(_Condition) \
347 if (! (_Condition)) \
348 std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
353 // Macros for race detectors.
354 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and
355 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain
356 // atomic (lock-free) synchronization to race detectors:
357 // the race detector will infer a happens-before arc from the former to the
358 // latter when they share the same argument pointer.
360 // The most frequent use case for these macros (and the only case in the
361 // current implementation of the library) is atomic reference counting:
362 // void _M_remove_reference()
364 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
365 // if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0)
367 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
371 // The annotations in this example tell the race detector that all memory
372 // accesses occurred when the refcount was positive do not race with
373 // memory accesses which occurred after the refcount became zero.
374 #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE
375 # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A)
377 #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER
378 # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A)
381 // Macros for C linkage: define extern "C" linkage only when using C++.
382 # define _GLIBCXX_BEGIN_EXTERN_C extern "C" {
383 # define _GLIBCXX_END_EXTERN_C }
385 #else // !__cplusplus
386 # define _GLIBCXX_BEGIN_EXTERN_C
387 # define _GLIBCXX_END_EXTERN_C
393 // Pick up any OS-specific definitions.
394 #include <bits/os_defines.h>
396 // Pick up any CPU-specific definitions.
397 #include <bits/cpu_defines.h>
399 // If platform uses neither visibility nor psuedo-visibility,
400 // specify empty default for namespace annotation macros.
401 #ifndef _GLIBCXX_PSEUDO_VISIBILITY
402 # define _GLIBCXX_PSEUDO_VISIBILITY(V)
405 // Certain function definitions that are meant to be overridable from
406 // user code are decorated with this macro. For some targets, this
407 // macro causes these definitions to be weak.
408 #ifndef _GLIBCXX_WEAK_DEFINITION
409 # define _GLIBCXX_WEAK_DEFINITION
413 // The remainder of the prewritten config is automatic; all the
414 // user hooks are listed above.
416 // Create a boolean flag to be used to determine if --fast-math is set.
418 # define _GLIBCXX_FAST_MATH 1
420 # define _GLIBCXX_FAST_MATH 0
423 // This marks string literals in header files to be extracted for eventual
424 // translation. It is primarily used for messages in thrown exceptions; see
425 // src/functexcept.cc. We use __N because the more traditional _N is used
426 // for something else under certain OSes (see BADNAMES).
427 #define __N(msgid) (msgid)
429 // For example, <windows.h> is known to #define min and max as macros...
433 // End of prewritten config; the settings discovered at configure time follow.