libstdc++
debug.h
Go to the documentation of this file.
00001 // Debugging support implementation -*- C++ -*-
00002 
00003 // Copyright (C) 2003-2015 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 3, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License and
00021 // a copy of the GCC Runtime Library Exception along with this program;
00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023 // <http://www.gnu.org/licenses/>.
00024 
00025 /** @file debug/debug.h
00026  *  This file is a GNU debug extension to the Standard C++ Library.
00027  */
00028 
00029 #ifndef _GLIBCXX_DEBUG_MACRO_SWITCH_H
00030 #define _GLIBCXX_DEBUG_MACRO_SWITCH_H 1
00031 
00032 /** Macros and namespaces used by the implementation outside of debug
00033  *  wrappers to verify certain properties. The __glibcxx_requires_xxx
00034  *  macros are merely wrappers around the __glibcxx_check_xxx wrappers
00035  *  when we are compiling with debug mode, but disappear when we are
00036  *  in release mode so that there is no checking performed in, e.g.,
00037  *  the standard library algorithms.
00038 */
00039 
00040 // Debug mode namespaces.
00041 
00042 /**
00043  * @namespace std::__debug
00044  * @brief GNU debug code, replaces standard behavior with debug behavior.
00045  */
00046 namespace std
00047 { 
00048   namespace __debug { } 
00049 }
00050 
00051 /** @namespace __gnu_debug
00052  *  @brief GNU debug classes for public use.
00053 */
00054 namespace __gnu_debug
00055 {
00056   using namespace std::__debug;
00057 }
00058 
00059 #ifndef _GLIBCXX_DEBUG
00060 
00061 # define _GLIBCXX_DEBUG_ASSERT(_Condition)
00062 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
00063 # define _GLIBCXX_DEBUG_ONLY(_Statement) ;
00064 # define __glibcxx_requires_cond(_Cond,_Msg)
00065 # define __glibcxx_requires_valid_range(_First,_Last)
00066 # define __glibcxx_requires_non_empty_range(_First,_Last)
00067 # define __glibcxx_requires_sorted(_First,_Last)
00068 # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred)
00069 # define __glibcxx_requires_sorted_set(_First1,_Last1,_First2)
00070 # define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred)
00071 # define __glibcxx_requires_partitioned_lower(_First,_Last,_Value)
00072 # define __glibcxx_requires_partitioned_upper(_First,_Last,_Value)
00073 # define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred)
00074 # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred)
00075 # define __glibcxx_requires_heap(_First,_Last)
00076 # define __glibcxx_requires_heap_pred(_First,_Last,_Pred)
00077 # define __glibcxx_requires_nonempty()
00078 # define __glibcxx_requires_string(_String)
00079 # define __glibcxx_requires_string_len(_String,_Len)
00080 # define __glibcxx_requires_subscript(_N)
00081 
00082 #else
00083 
00084 # include <debug/macros.h>
00085 
00086 #define _GLIBCXX_DEBUG_ASSERT(_Condition) __glibcxx_assert(_Condition)
00087 
00088 #ifdef _GLIBCXX_DEBUG_PEDANTIC
00089 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition)
00090 #else
00091 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
00092 #endif
00093 
00094 # define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement
00095 
00096 # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg)
00097 # define __glibcxx_requires_valid_range(_First,_Last) \
00098      __glibcxx_check_valid_range(_First,_Last)
00099 # define __glibcxx_requires_non_empty_range(_First,_Last) \
00100      __glibcxx_check_non_empty_range(_First,_Last)
00101 # define __glibcxx_requires_sorted(_First,_Last) \
00102      __glibcxx_check_sorted(_First,_Last)
00103 # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \
00104      __glibcxx_check_sorted_pred(_First,_Last,_Pred)
00105 # define __glibcxx_requires_sorted_set(_First1,_Last1,_First2) \
00106      __glibcxx_check_sorted_set(_First1,_Last1,_First2)
00107 # define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred) \
00108      __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred)
00109 # define __glibcxx_requires_partitioned_lower(_First,_Last,_Value)      \
00110      __glibcxx_check_partitioned_lower(_First,_Last,_Value)
00111 # define __glibcxx_requires_partitioned_upper(_First,_Last,_Value)      \
00112      __glibcxx_check_partitioned_upper(_First,_Last,_Value)
00113 # define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
00114      __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred)
00115 # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
00116      __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred)
00117 # define __glibcxx_requires_heap(_First,_Last) \
00118      __glibcxx_check_heap(_First,_Last)
00119 # define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \
00120      __glibcxx_check_heap_pred(_First,_Last,_Pred)
00121 # define __glibcxx_requires_nonempty() __glibcxx_check_nonempty()
00122 # define __glibcxx_requires_string(_String) __glibcxx_check_string(_String)
00123 # define __glibcxx_requires_string_len(_String,_Len)    \
00124      __glibcxx_check_string_len(_String,_Len)
00125 # define __glibcxx_requires_subscript(_N) __glibcxx_check_subscript(_N)
00126 
00127 # include <debug/functions.h>
00128 
00129 #endif
00130 
00131 #endif // _GLIBCXX_DEBUG_MACRO_SWITCH_H