source: NonGTP/FCollada/Documentation/_f_u_assert_8h-source.html @ 964

Revision 964, 6.9 KB checked in by igarcia, 19 years ago (diff)
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3<title>FCollada: FUtils/FUAssert.h Source File</title>
4<link href="doxygen.css" rel="stylesheet" type="text/css">
5<link href="tabs.css" rel="stylesheet" type="text/css">
6</head><body>
7<!-- Generated by Doxygen 1.4.6-NO -->
8<div class="tabs">
9  <ul>
10    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
11    <li><a href="modules.html"><span>Modules</span></a></li>
12    <li><a href="namespaces.html"><span>Namespaces</span></a></li>
13    <li><a href="classes.html"><span>Classes</span></a></li>
14    <li id="current"><a href="files.html"><span>Files</span></a></li>
15    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
16  </ul></div>
17<div class="tabs">
18  <ul>
19    <li><a href="files.html"><span>File&nbsp;List</span></a></li>
20    <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
21  </ul></div>
22<h1>FUtils/FUAssert.h</h1><a href="_f_u_assert_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
23<a name="l00002"></a>00002 <span class="comment">    Copyright (C) 2005-2006 Feeling Software Inc.</span>
24<a name="l00003"></a>00003 <span class="comment">    MIT License: http://www.opensource.org/licenses/mit-license.php</span>
25<a name="l00004"></a>00004 <span class="comment">*/</span>
26<a name="l00005"></a>00005
27<a name="l00011"></a>00011 <span class="preprocessor">#ifndef _FU_ASSERT_H_</span>
28<a name="l00012"></a>00012 <span class="preprocessor"></span><span class="preprocessor">#define _FU_ASSERT_H_</span>
29<a name="l00013"></a>00013 <span class="preprocessor"></span>
30<a name="l00020"></a>00020 <span class="preprocessor">#ifdef _DEBUG</span>
31<a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#ifdef WIN32</span>
32<a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor">#define __DEBUGGER_BREAK \</span>
33<a name="l00023"></a>00023 <span class="preprocessor">    static bool ignoreAssert = false; \</span>
34<a name="l00024"></a>00024 <span class="preprocessor">    if (!ignoreAssert) { \</span>
35<a name="l00025"></a>00025 <span class="preprocessor">        fchar message[1024]; \</span>
36<a name="l00026"></a>00026 <span class="preprocessor">        fsnprintf(message, 1024, FC("[%s@%u] Assertion failed.\nAbort: Enter debugger.\nRetry: Continue execution.\nIgnore: Do not assert at this line for the duration of the application."), FC(__FILE__), __LINE__); \</span>
37<a name="l00027"></a>00027 <span class="preprocessor">        message[1023] = 0; \</span>
38<a name="l00028"></a>00028 <span class="preprocessor">        int32 buttonPressed = MessageBox(NULL, message, FC("Assertion failed."), MB_ABORTRETRYIGNORE | MB_ICONWARNING); \</span>
39<a name="l00029"></a>00029 <span class="preprocessor">        if (buttonPressed == IDABORT) { \</span>
40<a name="l00030"></a>00030 <span class="preprocessor">            __asm int 3 \</span>
41<a name="l00031"></a>00031 <span class="preprocessor">        } else if (buttonPressed == IDRETRY) {} \</span>
42<a name="l00032"></a>00032 <span class="preprocessor">        else if (buttonPressed == IDIGNORE) { ignoreAssert = true; } }</span>
43<a name="l00033"></a>00033 <span class="preprocessor"></span>
44<a name="l00034"></a>00034 <span class="preprocessor">#else</span>
45<a name="l00035"></a>00035 <span class="preprocessor"></span>
46<a name="l00036"></a>00036 <span class="comment">// On non-Windows platforms: force a crash?</span>
47<a name="l00037"></a>00037 <span class="preprocessor">#define __DEBUGGER_BREAK { \</span>
48<a name="l00038"></a>00038 <span class="preprocessor">    uint32* __p = NULL; \</span>
49<a name="l00039"></a>00039 <span class="preprocessor">    uint32 __v = *__p; \</span>
50<a name="l00040"></a>00040 <span class="preprocessor">    *__p = 0xD1ED0D1E; \</span>
51<a name="l00041"></a>00041 <span class="preprocessor">    __v = __v + 1; }</span>
52<a name="l00042"></a>00042 <span class="preprocessor"></span>
53<a name="l00043"></a>00043 <span class="preprocessor">#endif // WIN32</span>
54<a name="l00044"></a>00044 <span class="preprocessor"></span><span class="preprocessor">#else</span>
55<a name="l00045"></a>00045 <span class="preprocessor"></span>
56<a name="l00051"></a><a class="code" href="_f_u_assert_8h.html#8be9594f924b19bb72ce88afbff5ae63">00051</a> <span class="preprocessor">#define __DEBUGGER_BREAK</span>
57<a name="l00052"></a>00052 <span class="preprocessor"></span>
58<a name="l00053"></a>00053 <span class="preprocessor">#endif // _DEBUG</span>
59<a name="l00054"></a>00054 <span class="preprocessor"></span>
60<a name="l00057"></a><a class="code" href="_f_u_assert_8h.html#2aaf258bf29e8c9d10c172100670807d">00057</a> <span class="preprocessor">#define FUFail(command) { __DEBUGGER_BREAK; command; }</span>
61<a name="l00058"></a>00058 <span class="preprocessor"></span>
62<a name="l00064"></a><a class="code" href="_f_u_assert_8h.html#72b8444eb608787f1db6bf1d53e0310f">00064</a> <span class="preprocessor">#define FUAssert(condition, fall_back) { if (!(condition)) { __DEBUGGER_BREAK; fall_back; } }</span>
63<a name="l00065"></a>00065 <span class="preprocessor"></span>
64<a name="l00066"></a>00066 <span class="preprocessor">#ifdef _DEBUG</span>
65<a name="l00067"></a>00067 <span class="preprocessor"></span><span class="preprocessor">#ifdef WIN32</span>
66<a name="l00068"></a>00068 <span class="preprocessor"></span>
67<a name="l00069"></a>00069 <span class="preprocessor">#define FUCheckMemory(fallback) FUAssert(_CrtCheckMemory(), fallback);</span>
68<a name="l00070"></a>00070 <span class="preprocessor"></span>
69<a name="l00071"></a>00071 <span class="preprocessor">#else // WIN32</span>
70<a name="l00072"></a>00072 <span class="preprocessor"></span>
71<a name="l00073"></a>00073 <span class="comment">// I don't know if there is a Linux equivalent.</span>
72<a name="l00074"></a>00074 <span class="preprocessor">#define FUCheckMemory(fallback)</span>
73<a name="l00075"></a>00075 <span class="preprocessor"></span>
74<a name="l00076"></a>00076 <span class="preprocessor">#endif // WIN32</span>
75<a name="l00077"></a>00077 <span class="preprocessor"></span><span class="preprocessor">#else // _DEBUG</span>
76<a name="l00078"></a>00078 <span class="preprocessor"></span>
77<a name="l00082"></a><a class="code" href="_f_u_assert_8h.html#3f8e304ec999fd5b47b525eac6fa3f4d">00082</a> <span class="preprocessor">#define FUCheckMemory(fallback)</span>
78<a name="l00083"></a>00083 <span class="preprocessor"></span>
79<a name="l00084"></a>00084 <span class="preprocessor">#endif</span>
80<a name="l00085"></a>00085 <span class="preprocessor"></span>
81<a name="l00086"></a>00086 <span class="preprocessor">#endif // _FU_ASSERT_H_</span>
82</pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri May 12 16:44:39 2006 for FCollada by&nbsp;
83<a href="http://www.doxygen.org/index.html">
84<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6-NO </small></address>
85</body>
86</html>
Note: See TracBrowser for help on using the repository browser.