libstdc++
debug.h
Go to the documentation of this file.
1 // Debugging support implementation -*- C++ -*-
2 
3 // Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
4 // Free Software Foundation, Inc.
5 //
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)
10 // any later version.
11 
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.
16 
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.
20 
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/>.
25 
26 /** @file debug/debug.h
27  * This file is a GNU debug extension to the Standard C++ Library.
28  */
29 
30 #ifndef _GLIBCXX_DEBUG_MACRO_SWITCH_H
31 #define _GLIBCXX_DEBUG_MACRO_SWITCH_H 1
32 
33 /** Macros and namespaces used by the implementation outside of debug
34  * wrappers to verify certain properties. The __glibcxx_requires_xxx
35  * macros are merely wrappers around the __glibcxx_check_xxx wrappers
36  * when we are compiling with debug mode, but disappear when we are
37  * in release mode so that there is no checking performed in, e.g.,
38  * the standard library algorithms.
39 */
40 
41 // Debug mode namespaces.
42 
43 /**
44  * @namespace std::__debug
45  * @brief GNU debug code, replaces standard behavior with debug behavior.
46  */
47 namespace std
48 {
49  namespace __debug { }
50 }
51 
52 /** @namespace __gnu_debug
53  * @brief GNU debug classes for public use.
54 */
55 namespace __gnu_debug
56 {
57  using namespace std::__debug;
58 }
59 
60 #ifndef _GLIBCXX_DEBUG
61 
62 # define _GLIBCXX_DEBUG_ASSERT(_Condition)
63 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
64 # define _GLIBCXX_DEBUG_ONLY(_Statement) ;
65 # define __glibcxx_requires_cond(_Cond,_Msg)
66 # define __glibcxx_requires_valid_range(_First,_Last)
67 # define __glibcxx_requires_non_empty_range(_First,_Last)
68 # define __glibcxx_requires_sorted(_First,_Last)
69 # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred)
70 # define __glibcxx_requires_sorted_set(_First1,_Last1,_First2)
71 # define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred)
72 # define __glibcxx_requires_partitioned_lower(_First,_Last,_Value)
73 # define __glibcxx_requires_partitioned_upper(_First,_Last,_Value)
74 # define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred)
75 # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred)
76 # define __glibcxx_requires_heap(_First,_Last)
77 # define __glibcxx_requires_heap_pred(_First,_Last,_Pred)
78 # define __glibcxx_requires_nonempty()
79 # define __glibcxx_requires_string(_String)
80 # define __glibcxx_requires_string_len(_String,_Len)
81 # define __glibcxx_requires_subscript(_N)
82 
83 #else
84 
85 # include <debug/macros.h>
86 
87 #define _GLIBCXX_DEBUG_ASSERT(_Condition) __glibcxx_assert(_Condition)
88 
89 #ifdef _GLIBCXX_DEBUG_PEDANTIC
90 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition)
91 #else
92 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
93 #endif
94 
95 # define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement
96 
97 # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg)
98 # define __glibcxx_requires_valid_range(_First,_Last) \
99  __glibcxx_check_valid_range(_First,_Last)
100 # define __glibcxx_requires_non_empty_range(_First,_Last) \
101  __glibcxx_check_non_empty_range(_First,_Last)
102 # define __glibcxx_requires_sorted(_First,_Last) \
103  __glibcxx_check_sorted(_First,_Last)
104 # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \
105  __glibcxx_check_sorted_pred(_First,_Last,_Pred)
106 # define __glibcxx_requires_sorted_set(_First1,_Last1,_First2) \
107  __glibcxx_check_sorted_set(_First1,_Last1,_First2)
108 # define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred) \
109  __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred)
110 # define __glibcxx_requires_partitioned_lower(_First,_Last,_Value) \
111  __glibcxx_check_partitioned_lower(_First,_Last,_Value)
112 # define __glibcxx_requires_partitioned_upper(_First,_Last,_Value) \
113  __glibcxx_check_partitioned_upper(_First,_Last,_Value)
114 # define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
115  __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred)
116 # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
117  __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred)
118 # define __glibcxx_requires_heap(_First,_Last) \
119  __glibcxx_check_heap(_First,_Last)
120 # define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \
121  __glibcxx_check_heap_pred(_First,_Last,_Pred)
122 # define __glibcxx_requires_nonempty() __glibcxx_check_nonempty()
123 # define __glibcxx_requires_string(_String) __glibcxx_check_string(_String)
124 # define __glibcxx_requires_string_len(_String,_Len) \
125  __glibcxx_check_string_len(_String,_Len)
126 # define __glibcxx_requires_subscript(_N) __glibcxx_check_subscript(_N)
127 
128 # include <debug/functions.h>
129 
130 #endif
131 
132 #endif // _GLIBCXX_DEBUG_MACRO_SWITCH_H