File: debug.h

package info (click to toggle)
wxpython3.0 3.0.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 482,760 kB
  • ctags: 518,293
  • sloc: cpp: 2,127,226; python: 294,045; makefile: 51,942; ansic: 19,033; sh: 3,013; xml: 1,629; perl: 17
file content (389 lines) | stat: -rw-r--r-- 12,210 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
/////////////////////////////////////////////////////////////////////////////
// Name:        wx/debug.h
// Purpose:     interface of global functions
// Author:      wxWidgets team
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

/** @addtogroup group_funcmacro_debug */
//@{

/**
    Exits the program immediately.

    This is a simple wrapper for the standard abort() function which is not
    available under all platforms (currently only Windows CE doesn't provide
    it).

    @since 2.9.4
 */
void wxAbort();

/**
    @def wxDEBUG_LEVEL

    Preprocessor symbol defining the level of debug support available.

    This symbol is defined to 1 by default meaning that asserts are compiled in
    (although they may be disabled by a call to wxDisableAsserts()). You may
    predefine it as 0 prior to including any wxWidgets headers to omit the
    calls to wxASSERT() and related macros entirely in your own code and you
    may also predefine it as 0 when building wxWidgets to also avoid including
    any asserts in wxWidgets itself.

    Alternatively, you may predefine it as 2 to include wxASSERT_LEVEL_2() and
    similar macros which are used for asserts which have non-trivial run-time
    costs and so are disabled by default.

    @since 2.9.1

    @header{wx/debug.h}
 */
#define wxDEBUG_LEVEL

/**
    @def __WXDEBUG__

    Compatibility macro indicating presence of debug support.

    This symbol is defined if wxDEBUG_LEVEL is greater than 0 and undefined
    otherwise.

    @header{wx/debug.h}
 */
#define __WXDEBUG__

/**
    Type for the function called in case of assert failure.

    @see wxSetAssertHandler()
 */
typedef void (*wxAssertHandler_t)(const wxString& file,
                                  int line,
                                  const wxString& func,
                                  const wxString& cond,
                                  const wxString& msg);

/**
    Assert macro. An error message will be generated if the condition is @false in
    debug mode, but nothing will be done in the release build.

    Please note that the condition in wxASSERT() should have no side effects
    because it will not be executed in release mode at all.

    This macro should be used to catch (in debug builds) logical errors done
    by the programmer.

    @see wxASSERT_MSG(), wxCOMPILE_TIME_ASSERT()

    @header{wx/debug.h}
*/
#define wxASSERT( condition )

/**
    Assert macro for expensive run-time checks.

    This macro does nothing unless wxDEBUG_LEVEL is 2 or more and is meant to
    be used for the assertions with noticeable performance impact and which,
    hence, should be disabled during run-time.

    If wxDEBUG_LEVEL is 2 or more, it becomes the same as wxASSERT().

    @header{wx/debug.h}
 */
#define wxASSERT_LEVEL_2( condition )

/**
    Assert macro with a custom message for expensive run-time checks.

    If wxDEBUG_LEVEL is 2 or more, this is the same as wxASSERT_MSG(),
    otherwise it doesn't do anything at all.

    @see wxASSERT_LEVEL_2()

    @header{wx/debug.h}
 */
#define wxASSERT_LEVEL_2_MSG( condition, msg)


/**
    This macro results in a @ref wxCOMPILE_TIME_ASSERT "compile time assertion failure"
    if the size of the given @c type is less than @c size bits.

    This macro should be used to catch (in debug builds) logical errors done
    by the programmer.

    You may use it like this, for example:

    @code
    // we rely on the int being able to hold values up to 2^32
    wxASSERT_MIN_BITSIZE(int, 32);

    // can't work with the platforms using UTF-8 for wchar_t
    wxASSERT_MIN_BITSIZE(wchar_t, 16);
    @endcode

    @header{wx/debug.h}
*/
#define wxASSERT_MIN_BITSIZE( type, size )

/**
    Assert macro with message.
    An error message will be generated if the condition is @false.

    This macro should be used to catch (in debug builds) logical errors done
    by the programmer.

    @see wxASSERT(), wxCOMPILE_TIME_ASSERT()

    @header{wx/debug.h}
*/
#define wxASSERT_MSG( condition, message )

/**
    Checks that the condition is @true, returns with the given return value if
    not (stops execution in debug mode). This check is done even in release mode.

    This macro should be used to catch (both in debug and release builds) logical
    errors done by the programmer.

    @header{wx/debug.h}
*/
#define wxCHECK( condition, retValue )

/**
    Checks that the condition is @true, returns with the given return value if
    not (stops execution in debug mode). This check is done even in release mode.

    This macro may be only used in non-void functions, see also wxCHECK_RET().

    This macro should be used to catch (both in debug and release builds) logical
    errors done by the programmer.

    @header{wx/debug.h}
*/
#define wxCHECK_MSG( condition, retValue, message )

/**
    Checks that the condition is @true, and returns if not (stops execution
    with the given error message in debug mode). This check is done even in
    release mode.

    This macro should be used in void functions instead of wxCHECK_MSG().

    This macro should be used to catch (both in debug and release builds) logical
    errors done by the programmer.

    @header{wx/debug.h}
*/
#define wxCHECK_RET( condition, message )

/**
    Checks that the condition is @true, and if not, it will wxFAIL() and
    execute the given @c operation if it is not. This is a generalisation of
    wxCHECK() and may be used when something else than just returning from the
    function must be done when the @c condition is @false. This check is done
    even in release mode.

    This macro should be used to catch (both in debug and release builds) logical
    errors done by the programmer.

    @header{wx/debug.h}
*/
#define wxCHECK2(condition, operation)

/**
    This is the same as wxCHECK2(), but wxFAIL_MSG() with the specified
    @c message is called instead of wxFAIL() if the @c condition is @false.

    This macro should be used to catch (both in debug and release builds) logical
    errors done by the programmer.

    @header{wx/debug.h}
*/
#define wxCHECK2_MSG( condition, operation, message )

/**
    Using wxCOMPILE_TIME_ASSERT() results in a compilation error if the
    specified @c condition is @false. The compiler error message should include
    the @c message identifier - please note that it must be a valid C++
    identifier and not a string unlike in the other cases.

    This macro is mostly useful for testing the expressions involving the
    @c sizeof operator as they can't be tested by the preprocessor but it is
    sometimes desirable to test them at the compile time.

    Note that this macro internally declares a struct whose name it tries to
    make unique by using the @c __LINE__ in it but it may still not work if you
    use it on the same line in two different source files. In this case you may
    either change the line in which either of them appears on or use the
    wxCOMPILE_TIME_ASSERT2() macro.

    Also note that Microsoft Visual C++ has a bug which results in compiler
    errors if you use this macro with 'Program Database For Edit And Continue'
    (@c /ZI) option, so you shouldn't use it ('Program Database' (@c /Zi) is ok
    though) for the code making use of this macro.

    This macro should be used to catch misconfigurations at compile-time.

    @see wxASSERT_MSG(), wxASSERT_MIN_BITSIZE()

    @header{wx/debug.h}
*/
#define wxCOMPILE_TIME_ASSERT( condition, message )

/**
    This macro is identical to wxCOMPILE_TIME_ASSERT() except that it allows
    you to specify a unique @c name for the struct internally defined by this
    macro to avoid getting the compilation errors described for
    wxCOMPILE_TIME_ASSERT().

    This macro should be used to catch misconfigurations at compile-time.

    @header{wx/debug.h}
*/
#define wxCOMPILE_TIME_ASSERT2(condition, message, name)

/**
    Disable the condition checks in the assertions.

    This is the same as calling wxSetAssertHandler() with @NULL handler.

    @since 2.9.0

    @header{wx/debug.h}
 */
void wxDisableAsserts();

/**
    @def wxDISABLE_ASSERTS_IN_RELEASE_BUILD

    Use this macro to disable asserts in release build when not using
    wxIMPLEMENT_APP().

    By default, assert message boxes are suppressed in release build by
    wxIMPLEMENT_APP() which uses this macro. If you don't use wxIMPLEMENT_APP()
    because your application initializes wxWidgets directly (e.g. calls
    wxEntry() or wxEntryStart() itself) but still want to suppress assert
    notifications in release build you need to use this macro directly.

    @see wxDISABLE_DEBUG_SUPPORT()

    @since 2.9.1

    @header{wx/debug.h}
 */
#define wxDISABLE_ASSERTS_IN_RELEASE_BUILD() wxDisableAsserts()

/**
    Will always generate an assert error if this code is reached (in debug mode).
    Note that you don't have to (and cannot) use brackets when invoking this
    macro:

    @code
        if (...some condition...) {
            wxFAIL;
        }
    @endcode

    This macro should be used to catch (in debug builds) logical errors done
    by the programmer.

    @see wxFAIL_MSG()

    @header{wx/debug.h}
*/
#define wxFAIL

/**
    Will always generate an assert error with specified message if this code is
    reached (in debug mode).

    This macro is useful for marking "unreachable" code areas, for example it
    may be used in the "default:" branch of a switch statement if all possible
    cases are processed above.

    This macro should be used to catch (in debug builds) logical errors done
    by the programmer.

    @see wxFAIL()

    @header{wx/debug.h}
*/
#define wxFAIL_MSG( message )

/**
    Returns @true if the program is running under debugger, @false otherwise.

    Please note that this function is currently only implemented for Win32 and
    always returns @false elsewhere.

    @header{wx/debug.h}
*/
bool wxIsDebuggerRunning();

/**
    Sets the function to be called in case of assertion failure.

    The default assert handler forwards to wxApp::OnAssertFailure() whose
    default behaviour is, in turn, to show the standard assertion failure
    dialog if a wxApp object exists or shows the same dialog itself directly
    otherwise.

    While usually it is enough -- and more convenient -- to just override
    OnAssertFailure(), to handle all assertion failures, including those
    occurring even before wxApp object creation of after its destruction you
    need to provide your assertion handler function.

    This function also provides a simple way to disable all asserts: simply
    pass @NULL pointer to it. Doing this will result in not even evaluating
    assert conditions at all, avoiding almost all run-time cost of asserts.

    Notice that this function is not MT-safe, so you should call it before
    starting any other threads.

    The return value of this function is the previous assertion handler. It can
    be called after any pre-processing by your handler and can also be restored
    later if you uninstall your handler.

    @param handler
        The function to call in case of assertion failure or @NULL.
    @return
        The previous assert handler which is not @NULL by default but could be
        @NULL if it had been previously set to this value using this function.

    @since 2.9.0

    @header{wx/debug.h}
 */
wxAssertHandler_t wxSetAssertHandler(wxAssertHandler_t handler);

/**
    Reset the assert handler to default function which shows a message box when
    an assert happens.

    This can be useful for the applications compiled in release build (with @c
    NDEBUG defined) for which the asserts are by default disabled: if you wish
    to enable them even in this case you need to call this function.

    @since 2.9.1

    @header{wx/debug.h}
 */
void wxSetDefaultAssertHandler();

/**
    Generate a debugger exception meaning that the control is passed to the
    debugger if one is attached to the process.

    Otherwise the program just terminates abnormally.

    If @c wxDEBUG_LEVEL is 0 (which is not the default) this function does
    nothing.

    @header{wx/debug.h}
*/
void wxTrap();

//@}