]> git.saurik.com Git - wxWidgets.git/blame - interface/debug.h
Fixed some function/define paramter names to match old docs.
[wxWidgets.git] / interface / debug.h
CommitLineData
23324ae1 1/////////////////////////////////////////////////////////////////////////////
7c913512 2// Name: debug.h
e54c96f1 3// Purpose: interface of global functions
7c913512
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10Will always generate an assert error if this code is reached (in debug mode).
e54c96f1 11See also: wxFAIL_MSG()
23324ae1 12*/
4cc4bfaf 13wxFAIL();
23324ae1
FM
14
15
7c913512
FM
16/**
17This function is called whenever one of debugging macros fails (i.e. condition
18is @false in an assertion). It is only defined in the debug mode, in release
e54c96f1 19builds the wxCHECK() failures don't result in anything.
7c913512
FM
20To override the default behaviour in the debug builds which is to show the user
21a dialog asking whether he wants to abort the program, continue or continue
22ignoring any subsequent assert failures, you may override
23wxApp::OnAssertFailure which is called by this function if
24the global application object exists.
23324ae1 25*/
4cc4bfaf
FM
26void wxOnAssert(const char* fileName, int lineNumber,
27 const char* func,
28 const char* cond,
29 const char* msg = NULL);
23324ae1
FM
30
31/**
32 In debug mode (when @c __WXDEBUG__ is defined) this function generates a
33 debugger exception meaning that the control is passed to the debugger if one is
34 attached to the process. Otherwise the program just terminates abnormally.
23324ae1
FM
35 In release mode this function does nothing.
36*/
37void wxTrap();
38
39/**
40 Will always generate an assert error with specified message if this code is
41 reached (in debug mode).
23324ae1
FM
42 This macro is useful for marking unreachable" code areas, for example
43 it may be used in the "default:" branch of a switch statement if all possible
44 cases are processed above.
7c913512 45
e54c96f1 46 @see wxFAIL()
23324ae1
FM
47*/
48#define wxFAIL_MSG(msg) /* implementation is private */
49
50/**
51 Checks that the condition is @true, returns with the given return value if not
52 (FAILs in debug mode).
53 This check is done even in release mode.
54*/
4cc4bfaf 55#define wxCHECK(condition, retValue) /* implementation is private */
23324ae1
FM
56
57/**
58 This macro results in a
59 @ref overview_wxcompiletimeassert "compile time assertion failure" if the size
4cc4bfaf 60 of the given type @a type is less than @a size bits.
23324ae1 61 You may use it like this, for example:
4cc4bfaf 62
23324ae1
FM
63 @code
64 // we rely on the int being able to hold values up to 2^32
65 wxASSERT_MIN_BITSIZE(int, 32);
7c913512 66
23324ae1
FM
67 // can't work with the platforms using UTF-8 for wchar_t
68 wxASSERT_MIN_BITSIZE(wchar_t, 16);
69 @endcode
70*/
4cc4bfaf 71#define wxASSERT_MIN_BITSIZE(type, size) /* implementation is private */
23324ae1
FM
72
73/**
74 Assert macro with message. An error message will be generated if the condition
75 is @false.
7c913512 76
e54c96f1 77 @see wxASSERT(), wxCOMPILE_TIME_ASSERT()
23324ae1 78*/
4cc4bfaf 79#define wxASSERT_MSG(condition, msg) /* implementation is private */
23324ae1
FM
80
81/**
e54c96f1
FM
82 This is the same as wxCHECK2(), but
83 wxFAIL_MSG() with the specified @a msg is called
4cc4bfaf 84 instead of wxFAIL() if the @a condition is @false.
23324ae1 85*/
4cc4bfaf 86#define wxCHECK2(condition, operation, msg) /* implementation is private */
23324ae1
FM
87
88/**
89 Assert macro. An error message will be generated if the condition is @false in
90 debug mode, but nothing will be done in the release build.
23324ae1
FM
91 Please note that the condition in wxASSERT() should have no side effects
92 because it will not be executed in release mode at all.
7c913512 93
e54c96f1 94 @see wxASSERT_MSG(), wxCOMPILE_TIME_ASSERT()
23324ae1
FM
95*/
96#define wxASSERT(condition) /* implementation is private */
97
98/**
99 Checks that the condition is @true, and returns if not (FAILs with given error
100 message in debug mode). This check is done even in release mode.
23324ae1 101 This macro should be used in void functions instead of
e54c96f1 102 wxCHECK_MSG().
23324ae1 103*/
4cc4bfaf 104#define wxCHECK_RET(condition, msg) /* implementation is private */
23324ae1
FM
105
106/**
e54c96f1 107 Checks that the condition is @true and wxFAIL() and execute
4cc4bfaf 108 @a operation if it is not. This is a generalisation of
e54c96f1 109 wxCHECK() and may be used when something else than just
4cc4bfaf 110 returning from the function must be done when the @a condition is @false.
23324ae1
FM
111 This check is done even in release mode.
112*/
4cc4bfaf 113#define wxCHECK2(condition, operation) /* implementation is private */
23324ae1
FM
114
115/**
e54c96f1 116 This macro is identical to wxCOMPILE_TIME_ASSERT2()
4cc4bfaf 117 except that it allows you to specify a unique @a name for the struct
23324ae1 118 internally defined by this macro to avoid getting the compilation errors
e54c96f1 119 described above().
23324ae1 120*/
4cc4bfaf 121#define wxCOMPILE_TIME_ASSERT(condition, msg, name) /* implementation is private */
23324ae1
FM
122
123/**
124 Checks that the condition is @true, returns with the given return value if not
125 (FAILs in debug mode).
126 This check is done even in release mode.
23324ae1 127 This macro may be only used in non-void functions, see also
e54c96f1 128 wxCHECK_RET().
23324ae1 129*/
4cc4bfaf 130#define wxCHECK_MSG(condition, retValue, msg) /* implementation is private */
23324ae1
FM
131
132/**
133 Using @c wxCOMPILE_TIME_ASSERT results in a compilation error if the
4cc4bfaf
FM
134 specified @a condition is @false. The compiler error message should include
135 the @a msg identifier - please note that it must be a valid C++ identifier
23324ae1 136 and not a string unlike in the other cases.
23324ae1
FM
137 This macro is mostly useful for testing the expressions involving the
138 @c sizeof operator as they can't be tested by the preprocessor but it is
139 sometimes desirable to test them at the compile time.
23324ae1
FM
140 Note that this macro internally declares a struct whose name it tries to make
141 unique by using the @c __LINE__ in it but it may still not work if you
142 use it on the same line in two different source files. In this case you may
143 either change the line in which either of them appears on or use the
e54c96f1 144 wxCOMPILE_TIME_ASSERT2() macro.
23324ae1
FM
145 Also note that Microsoft Visual C++ has a bug which results in compiler errors
146 if you use this macro with 'Program Database For Edit And Continue'
147 (@c /ZI) option, so you shouldn't use it ('Program Database'
148 (@c /Zi) is ok though) for the code making use of this macro.
7c913512 149
e54c96f1 150 @see wxASSERT_MSG(), wxASSERT_MIN_BITSIZE()
23324ae1 151*/
4cc4bfaf 152#define wxCOMPILE_TIME_ASSERT(condition, msg) /* implementation is private */
23324ae1 153