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__))
56 #ifndef _GLIBCXX_NOTHROW
58 # define _GLIBCXX_NOTHROW __attribute__((__nothrow__))
62 // Macros for visibility attributes.
63 // _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
64 // _GLIBCXX_VISIBILITY
65 #define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
67 #if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
68 # define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V)))
70 // If this is not supplied by the OS-specific or CPU-specific
71 // headers included below, it will be defined to an empty default.
72 # define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V)
75 // Macros for deprecated attributes.
76 // _GLIBCXX_USE_DEPRECATED
77 // _GLIBCXX_DEPRECATED
78 #ifndef _GLIBCXX_USE_DEPRECATED
79 # define _GLIBCXX_USE_DEPRECATED 1
82 #if defined(__DEPRECATED) && defined(__GXX_EXPERIMENTAL_CXX0X__)
83 # define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__))
85 # define _GLIBCXX_DEPRECATED
90 // Macro for constexpr, to support in mixed 03/0x mode.
91 #ifndef _GLIBCXX_CONSTEXPR
92 # ifdef __GXX_EXPERIMENTAL_CXX0X__
93 # define _GLIBCXX_CONSTEXPR constexpr
94 # define _GLIBCXX_USE_CONSTEXPR constexpr
96 # define _GLIBCXX_CONSTEXPR
97 # define _GLIBCXX_USE_CONSTEXPR const
101 // Macro for noexcept, to support in mixed 03/0x mode.
102 #ifndef _GLIBCXX_NOEXCEPT
103 # ifdef __GXX_EXPERIMENTAL_CXX0X__
104 # define _GLIBCXX_NOEXCEPT noexcept
105 # define _GLIBCXX_USE_NOEXCEPT noexcept
106 # define _GLIBCXX_THROW(_EXC)
108 # define _GLIBCXX_NOEXCEPT
109 # define _GLIBCXX_USE_NOEXCEPT throw()
110 # define _GLIBCXX_THROW(_EXC) throw(_EXC)
114 #ifndef _GLIBCXX_NOTHROW
115 # define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT
118 // Macro for extern template, ie controling template linkage via use
119 // of extern keyword on template declaration. As documented in the g++
120 // manual, it inhibits all implicit instantiations and is used
121 // throughout the library to avoid multiple weak definitions for
122 // required types that are already explicitly instantiated in the
123 // library binary. This substantially reduces the binary size of
124 // resulting executables.
125 // Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern
126 // templates only in basic_string, thus activating its debug-mode
127 // checks even at -O0.
128 #define _GLIBCXX_EXTERN_TEMPLATE
131 Outline of libstdc++ namespaces.
135 namespace __debug { }
136 namespace __parallel { }
137 namespace __profile { }
138 namespace __cxx1998 { }
140 namespace __detail { }
142 namespace rel_ops { }
146 namespace placeholders { }
147 namespace regex_constants { }
148 namespace __detail { }
153 namespace decimal { }
156 namespace placeholders { }
157 namespace regex_constants { }
158 namespace this_thread { }
165 namespace __detail { }
168 For full details see:
169 http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html
173 typedef __SIZE_TYPE__ size_t;
174 typedef __PTRDIFF_TYPE__ ptrdiff_t;
176 #ifdef __GXX_EXPERIMENTAL_CXX0X__
177 typedef decltype(nullptr) nullptr_t;
182 // Defined if inline namespaces are used for versioning.
183 #define _GLIBCXX_INLINE_VERSION
185 // Inline namespace for symbol versioning.
186 #if _GLIBCXX_INLINE_VERSION
190 inline namespace __7 { }
192 namespace rel_ops { inline namespace __7 { } }
196 inline namespace __7 { }
197 namespace placeholders { inline namespace __7 { } }
198 namespace regex_constants { inline namespace __7 { } }
199 namespace __detail { inline namespace __7 { } }
203 { inline namespace __7 { } }
205 namespace decimal { inline namespace __7 { } }
207 namespace chrono { inline namespace __7 { } }
208 namespace placeholders { inline namespace __7 { } }
209 namespace regex_constants { inline namespace __7 { } }
210 namespace this_thread { inline namespace __7 { } }
212 namespace __detail { inline namespace __7 { } }
213 namespace __regex { inline namespace __7 { } }
218 inline namespace __7 { }
219 namespace __detail { inline namespace __7 { } }
221 # define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __7 {
222 # define _GLIBCXX_END_NAMESPACE_VERSION }
224 # define _GLIBCXX_BEGIN_NAMESPACE_VERSION
225 # define _GLIBCXX_END_NAMESPACE_VERSION
229 // Inline namespaces for special modes: debug, parallel, profile.
230 #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) \
231 || defined(_GLIBCXX_PROFILE)
234 // Non-inline namespace for components replaced by alternates in active mode.
237 #if _GLIBCXX_INLINE_VERSION
238 inline namespace __7 { }
242 // Inline namespace for debug mode.
243 # ifdef _GLIBCXX_DEBUG
244 inline namespace __debug { }
247 // Inline namespaces for parallel mode.
248 # ifdef _GLIBCXX_PARALLEL
249 inline namespace __parallel { }
252 // Inline namespaces for profile mode
253 # ifdef _GLIBCXX_PROFILE
254 inline namespace __profile { }
258 // Check for invalid usage and unsupported mixed-mode use.
259 # if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL)
260 # error illegal use of multiple inlined namespaces
262 # if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_DEBUG)
263 # error illegal use of multiple inlined namespaces
265 # if defined(_GLIBCXX_PROFILE) && defined(_GLIBCXX_PARALLEL)
266 # error illegal use of multiple inlined namespaces
269 // Check for invalid use due to lack for weak symbols.
270 # if __NO_INLINE__ && !__GXX_WEAK__
271 # warning currently using inlined namespace mode which may fail \
272 without inlining due to lack of weak symbols
276 // Macros for namespace scope. Either namespace std:: or the name
277 // of some nested namespace within it corresponding to the active mode.
281 // Macros for opening/closing conditional namespaces.
282 // _GLIBCXX_BEGIN_NAMESPACE_ALGO
283 // _GLIBCXX_END_NAMESPACE_ALGO
284 // _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
285 // _GLIBCXX_END_NAMESPACE_CONTAINER
286 #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PROFILE)
287 # define _GLIBCXX_STD_C __cxx1998
288 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \
289 namespace _GLIBCXX_STD_C { _GLIBCXX_BEGIN_NAMESPACE_VERSION
290 # define _GLIBCXX_END_NAMESPACE_CONTAINER \
291 } _GLIBCXX_END_NAMESPACE_VERSION
292 # undef _GLIBCXX_EXTERN_TEMPLATE
293 # define _GLIBCXX_EXTERN_TEMPLATE -1
296 #ifdef _GLIBCXX_PARALLEL
297 # define _GLIBCXX_STD_A __cxx1998
298 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO \
299 namespace _GLIBCXX_STD_A { _GLIBCXX_BEGIN_NAMESPACE_VERSION
300 # define _GLIBCXX_END_NAMESPACE_ALGO \
301 } _GLIBCXX_END_NAMESPACE_VERSION
304 #ifndef _GLIBCXX_STD_A
305 # define _GLIBCXX_STD_A std
308 #ifndef _GLIBCXX_STD_C
309 # define _GLIBCXX_STD_C std
312 #ifndef _GLIBCXX_BEGIN_NAMESPACE_ALGO
313 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO
316 #ifndef _GLIBCXX_END_NAMESPACE_ALGO
317 # define _GLIBCXX_END_NAMESPACE_ALGO
320 #ifndef _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
321 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
324 #ifndef _GLIBCXX_END_NAMESPACE_CONTAINER
325 # define _GLIBCXX_END_NAMESPACE_CONTAINER
328 // GLIBCXX_ABI Deprecated
329 // Define if compatibility should be provided for -mlong-double-64.
330 #undef _GLIBCXX_LONG_DOUBLE_COMPAT
332 // Inline namespace for long double 128 mode.
333 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
336 inline namespace __gnu_cxx_ldbl128 { }
338 # define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128::
339 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 {
340 # define _GLIBCXX_END_NAMESPACE_LDBL }
342 # define _GLIBCXX_NAMESPACE_LDBL
343 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL
344 # define _GLIBCXX_END_NAMESPACE_LDBL
348 #if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PARALLEL)
349 # define __glibcxx_assert(_Condition)
353 // Avoid the use of assert, because we're trying to keep the <cassert>
354 // include out of the mix.
356 __replacement_assert(const char* __file, int __line,
357 const char* __function, const char* __condition)
359 __builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line,
360 __function, __condition);
364 #define __glibcxx_assert(_Condition) \
367 if (! (_Condition)) \
368 std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
373 // Macros for race detectors.
374 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and
375 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain
376 // atomic (lock-free) synchronization to race detectors:
377 // the race detector will infer a happens-before arc from the former to the
378 // latter when they share the same argument pointer.
380 // The most frequent use case for these macros (and the only case in the
381 // current implementation of the library) is atomic reference counting:
382 // void _M_remove_reference()
384 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
385 // if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0)
387 // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
391 // The annotations in this example tell the race detector that all memory
392 // accesses occurred when the refcount was positive do not race with
393 // memory accesses which occurred after the refcount became zero.
394 #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE
395 # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A)
397 #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER
398 # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A)
401 // Macros for C linkage: define extern "C" linkage only when using C++.
402 # define _GLIBCXX_BEGIN_EXTERN_C extern "C" {
403 # define _GLIBCXX_END_EXTERN_C }
405 #else // !__cplusplus
406 # define _GLIBCXX_BEGIN_EXTERN_C
407 # define _GLIBCXX_END_EXTERN_C
413 // Pick up any OS-specific definitions.
414 #include <bits/os_defines.h>
416 // Pick up any CPU-specific definitions.
417 #include <bits/cpu_defines.h>
419 // If platform uses neither visibility nor psuedo-visibility,
420 // specify empty default for namespace annotation macros.
421 #ifndef _GLIBCXX_PSEUDO_VISIBILITY
422 # define _GLIBCXX_PSEUDO_VISIBILITY(V)
425 // Certain function definitions that are meant to be overridable from
426 // user code are decorated with this macro. For some targets, this
427 // macro causes these definitions to be weak.
428 #ifndef _GLIBCXX_WEAK_DEFINITION
429 # define _GLIBCXX_WEAK_DEFINITION
433 // The remainder of the prewritten config is automatic; all the
434 // user hooks are listed above.
436 // Create a boolean flag to be used to determine if --fast-math is set.
438 # define _GLIBCXX_FAST_MATH 1
440 # define _GLIBCXX_FAST_MATH 0
443 // This marks string literals in header files to be extracted for eventual
444 // translation. It is primarily used for messages in thrown exceptions; see
445 // src/functexcept.cc. We use __N because the more traditional _N is used
446 // for something else under certain OSes (see BADNAMES).
447 #define __N(msgid) (msgid)
449 // For example, <windows.h> is known to #define min and max as macros...
453 // End of prewritten config; the settings discovered at configure time follow.