]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/debug.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of global functions
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
9 /** @ingroup group_funcmacro_debug */
13 Assert macro. An error message will be generated if the condition is @false in
14 debug mode, but nothing will be done in the release build.
16 Please note that the condition in wxASSERT() should have no side effects
17 because it will not be executed in release mode at all.
19 This macro should be used to catch (in debug builds) logical errors done
22 @see wxASSERT_MSG(), wxCOMPILE_TIME_ASSERT()
26 #define wxASSERT( condition )
29 This macro results in a @ref wxCOMPILE_TIME_ASSERT "compile time assertion failure"
30 if the size of the given @c type is less than @c size bits.
32 This macro should be used to catch (in debug builds) logical errors done
35 You may use it like this, for example:
38 // we rely on the int being able to hold values up to 2^32
39 wxASSERT_MIN_BITSIZE(int, 32);
41 // can't work with the platforms using UTF-8 for wchar_t
42 wxASSERT_MIN_BITSIZE(wchar_t, 16);
47 #define wxASSERT_MIN_BITSIZE( type, size )
50 Assert macro with message.
51 An error message will be generated if the condition is @false.
53 This macro should be used to catch (in debug builds) logical errors done
56 @see wxASSERT(), wxCOMPILE_TIME_ASSERT()
60 #define wxASSERT_MSG( condition, message )
63 Checks that the condition is @true, returns with the given return value if
64 not (stops execution in debug mode). This check is done even in release mode.
66 This macro should be used to catch (both in debug and release builds) logical
67 errors done by the programmer.
71 #define wxCHECK( condition, retValue )
74 Checks that the condition is @true, returns with the given return value if
75 not (stops execution in debug mode). This check is done even in release mode.
77 This macro may be only used in non-void functions, see also wxCHECK_RET().
79 This macro should be used to catch (both in debug and release builds) logical
80 errors done by the programmer.
84 #define wxCHECK_MSG( condition, retValue, message )
87 Checks that the condition is @true, and returns if not (stops execution
88 with the given error message in debug mode). This check is done even in
91 This macro should be used in void functions instead of wxCHECK_MSG().
93 This macro should be used to catch (both in debug and release builds) logical
94 errors done by the programmer.
98 #define wxCHECK_RET( condition, message )
101 Checks that the condition is @true, and if not, it will wxFAIL() and
102 execute the given @c operation if it is not. This is a generalisation of
103 wxCHECK() and may be used when something else than just returning from the
104 function must be done when the @c condition is @false. This check is done
105 even in release mode.
107 This macro should be used to catch (both in debug and release builds) logical
108 errors done by the programmer.
112 #define wxCHECK2(condition, operation)
115 This is the same as wxCHECK2(), but wxFAIL_MSG() with the specified
116 @c message is called instead of wxFAIL() if the @c condition is @false.
118 This macro should be used to catch (both in debug and release builds) logical
119 errors done by the programmer.
123 #define wxCHECK2_MSG( condition, operation, message )
126 Using wxCOMPILE_TIME_ASSERT() results in a compilation error if the
127 specified @c condition is @false. The compiler error message should include
128 the @c message identifier - please note that it must be a valid C++
129 identifier and not a string unlike in the other cases.
131 This macro is mostly useful for testing the expressions involving the
132 @c sizeof operator as they can't be tested by the preprocessor but it is
133 sometimes desirable to test them at the compile time.
135 Note that this macro internally declares a struct whose name it tries to
136 make unique by using the @c __LINE__ in it but it may still not work if you
137 use it on the same line in two different source files. In this case you may
138 either change the line in which either of them appears on or use the
139 wxCOMPILE_TIME_ASSERT2() macro.
141 Also note that Microsoft Visual C++ has a bug which results in compiler
142 errors if you use this macro with 'Program Database For Edit And Continue'
143 (@c /ZI) option, so you shouldn't use it ('Program Database' (@c /Zi) is ok
144 though) for the code making use of this macro.
146 This macro should be used to catch misconfigurations at compile-time.
148 @see wxASSERT_MSG(), wxASSERT_MIN_BITSIZE()
152 #define wxCOMPILE_TIME_ASSERT( condition, message )
155 This macro is identical to wxCOMPILE_TIME_ASSERT() except that it allows
156 you to specify a unique @c name for the struct internally defined by this
157 macro to avoid getting the compilation errors described for
158 wxCOMPILE_TIME_ASSERT().
160 This macro should be used to catch misconfigurations at compile-time.
164 #define wxCOMPILE_TIME_ASSERT2(condition, message, name)
167 Will always generate an assert error if this code is reached (in debug mode).
168 Note that you don't have to (and cannot) use brackets when invoking this
172 if (...some condition...) {
177 This macro should be used to catch (in debug builds) logical errors done
187 Will always generate an assert error with specified message if this code is
188 reached (in debug mode).
190 This macro is useful for marking unreachable" code areas, for example it
191 may be used in the "default:" branch of a switch statement if all possible
192 cases are processed above.
194 This macro should be used to catch (in debug builds) logical errors done
201 #define wxFAIL_MSG( message )
204 Returns @true if the program is running under debugger, @false otherwise.
206 Please note that this function is currently only implemented for Win32 and
207 Mac builds using CodeWarrior and always returns @false elsewhere.
211 bool wxIsDebuggerRunning();
214 This function is called whenever one of debugging macros fails (i.e.
215 condition is @false in an assertion). It is only defined in the debug mode,
216 in release builds the wxCHECK() failures don't result in anything.
218 To override the default behaviour in the debug builds which is to show the
219 user a dialog asking whether he wants to abort the program, continue or
220 continue ignoring any subsequent assert failures, you may override
221 wxApp::OnAssertFailure() which is called by this function if the global
222 application object exists.
226 void wxOnAssert( const char* fileName
,
228 const char* function
,
229 const char* condition
,
230 const char* message
= NULL
);
233 In debug mode (when @c __WXDEBUG__ is defined) this function generates a
234 debugger exception meaning that the control is passed to the debugger if
235 one is attached to the process. Otherwise the program just terminates
236 abnormally. In release mode this function does nothing.
246 /** @ingroup group_funcmacro_misc */
250 This macro expands to the name of the current function if the compiler
251 supports any of @c __FUNCTION__, @c __func__ or equivalent variables or
252 macros or to @NULL if none of them is available.
256 #define __WXFUNCTION__