]>
git.saurik.com Git - wxWidgets.git/blob - interface/debug.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of global functions
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 Will always generate an assert error if this code is reached (in debug mode).
11 See also: wxFAIL_MSG()
17 This function is called whenever one of debugging macros fails (i.e. condition
18 is @false in an assertion). It is only defined in the debug mode, in release
19 builds the wxCHECK() failures don't result in anything.
20 To override the default behaviour in the debug builds which is to show the user
21 a dialog asking whether he wants to abort the program, continue or continue
22 ignoring any subsequent assert failures, you may override
23 wxApp::OnAssertFailure which is called by this function if
24 the global application object exists.
26 void wxOnAssert(const char* fileName
, int lineNumber
,
29 const char* msg
= NULL
);
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.
35 In release mode this function does nothing.
40 Will always generate an assert error with specified message if this code is
41 reached (in debug mode).
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.
48 #define wxFAIL_MSG(msg) /* implementation is private */
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.
55 #define wxCHECK(condition, retValue) /* implementation is private */
58 This macro results in a
59 @ref overview_wxcompiletimeassert "compile time assertion failure" if the size
60 of the given type @a type is less than @a size bits.
61 You may use it like this, for example:
64 // we rely on the int being able to hold values up to 2^32
65 wxASSERT_MIN_BITSIZE(int, 32);
67 // can't work with the platforms using UTF-8 for wchar_t
68 wxASSERT_MIN_BITSIZE(wchar_t, 16);
71 #define wxASSERT_MIN_BITSIZE(type, size) /* implementation is private */
74 Assert macro with message. An error message will be generated if the condition
77 @see wxASSERT(), wxCOMPILE_TIME_ASSERT()
79 #define wxASSERT_MSG(condition, msg) /* implementation is private */
82 This is the same as wxCHECK2(), but
83 wxFAIL_MSG() with the specified @a msg is called
84 instead of wxFAIL() if the @a condition is @false.
86 #define wxCHECK2(condition, operation, msg) /* implementation is private */
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.
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.
94 @see wxASSERT_MSG(), wxCOMPILE_TIME_ASSERT()
96 #define wxASSERT(condition) /* implementation is private */
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.
101 This macro should be used in void functions instead of
104 #define wxCHECK_RET(condition, msg) /* implementation is private */
107 Checks that the condition is @true and wxFAIL() and execute
108 @a operation if it is not. This is a generalisation of
109 wxCHECK() and may be used when something else than just
110 returning from the function must be done when the @a condition is @false.
111 This check is done even in release mode.
113 #define wxCHECK2(condition, operation) /* implementation is private */
116 This macro is identical to wxCOMPILE_TIME_ASSERT2()
117 except that it allows you to specify a unique @a name for the struct
118 internally defined by this macro to avoid getting the compilation errors
121 #define wxCOMPILE_TIME_ASSERT(condition, msg, name) /* implementation is private */
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.
127 This macro may be only used in non-void functions, see also
130 #define wxCHECK_MSG(condition, retValue, msg) /* implementation is private */
133 Using @c wxCOMPILE_TIME_ASSERT results in a compilation error if the
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
136 and not a string unlike in the other cases.
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.
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
144 wxCOMPILE_TIME_ASSERT2() macro.
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.
150 @see wxASSERT_MSG(), wxASSERT_MIN_BITSIZE()
152 #define wxCOMPILE_TIME_ASSERT(condition, msg) /* implementation is private */