Open Dynamics Engine
ode/src/error.h
1 /*************************************************************************
2  * *
3  * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
4  * All rights reserved. Email: russ@q12.org Web: www.q12.org *
5  * *
6  * This library is free software; you can redistribute it and/or *
7  * modify it under the terms of EITHER: *
8  * (1) The GNU Lesser General Public License as published by the Free *
9  * Software Foundation; either version 2.1 of the License, or (at *
10  * your option) any later version. The text of the GNU Lesser *
11  * General Public License is included with this library in the *
12  * file LICENSE.TXT. *
13  * (2) The BSD-style license that is included with this library in *
14  * the file LICENSE-BSD.TXT. *
15  * *
16  * This library is distributed in the hope that it will be useful, *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
19  * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
20  * *
21  *************************************************************************/
22 
23 /* Library private error handling functions and macros */
24 
25 #ifndef _ODE__PRIVATE_ERROR_H_
26 #define _ODE__PRIVATE_ERROR_H_
27 
28 #include <ode/error.h>
29 
30 
31 
32 /* debugging:
33  * IASSERT is an internal assertion, i.e. a consistency check. if it fails
34  * we want to know where.
35  * UASSERT is a user assertion, i.e. if it fails a nice error message
36  * should be printed for the user.
37  * AASSERT is an arguments assertion, i.e. if it fails "bad argument(s)"
38  * is printed.
39  * DEBUGMSG just prints out a message
40  */
41 
42 # if defined(__STDC__) && __STDC_VERSION__ >= 199901L
43 # define __FUNCTION__ __func__
44 # endif
45 #ifndef dNODEBUG
46 # ifdef __GNUC__
47 # define dIASSERT(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \
48  "assertion \"" #a "\" failed in %s() [%s:%u]",__FUNCTION__,__FILE__,__LINE__); } }
49 # define dUASSERT(a,msg) { if (!(a)) { dDebug (d_ERR_UASSERT, \
50  msg " in %s()", __FUNCTION__); } }
51 # define dDEBUGMSG(msg) { dMessage (d_ERR_UASSERT, \
52  msg " in %s() [%s:%u]", __FUNCTION__,__FILE__,__LINE__); }
53 # else // not __GNUC__
54 # define dIASSERT(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \
55  "assertion \"" #a "\" failed in %s:%u",__FILE__,__LINE__); } }
56 # define dUASSERT(a,msg) { if (!(a)) { dDebug (d_ERR_UASSERT, \
57  msg " (%s:%u)", __FILE__,__LINE__); } }
58 # define dDEBUGMSG(msg) { dMessage (d_ERR_UASSERT, \
59  msg " (%s:%u)", __FILE__,__LINE__); }
60 # endif
61 # define dIVERIFY(a) dIASSERT(a)
62 #else
63 # define dIASSERT(a) ((void)0)
64 # define dUASSERT(a,msg) ((void)0)
65 # define dDEBUGMSG(msg) ((void)0)
66 # define dIVERIFY(a) ((void)(a))
67 #endif
68 
69 # ifdef __GNUC__
70 # define dICHECK(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \
71  "assertion \"" #a "\" failed in %s() [%s:%u]",__FUNCTION__,__FILE__,__LINE__); *(int *)0 = 0; } }
72 # else // not __GNUC__
73 # define dICHECK(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \
74  "assertion \"" #a "\" failed in %s:%u",__FILE__,__LINE__); *(int *)0 = 0; } }
75 # endif
76 
77 // Argument assert is a special case of user assert
78 #define dAASSERT(a) dUASSERT(a,"Bad argument(s)")
79 
80 
81 #endif