27 #ifndef __DEBUG_STUFF__INCLUDED
28 #define __DEBUG_STUFF__INCLUDED
31 #if defined(_DEBUG) || !defined(NDEBUG)
32 #define ODA_DIAGNOSTICS
35 #ifdef ODA_DIAGNOSTICS
42 const char* expresssion,
const char* fileName,
int nLineNo);
44 #if defined(_MSC_VER) && _MSC_VER >= 1300
49 #define ODA_ASSERT(exp) ((!(exp)) ? OdAssert(#exp, __FILE__, __LINE__) : oda_noop())
50 #define ODA_VERIFY(exp) ODA_ASSERT(exp)
51 #define ODA_ASSERT_ONCE(exp)\
52 { static bool was_here = false;\
53 if (!was_here && !(exp))\
55 OdAssert(#exp, __FILE__, __LINE__);\
58 #define ODA_VERIFY_ONCE(exp)\
59 { static bool was_here = false;\
60 if (!(exp) && !was_here)\
62 OdAssert(#exp, __FILE__, __LINE__);\
65 #define ODA_FAIL() OdAssert("Invalid Execution.", __FILE__, __LINE__)
66 #define ODA_FAIL_ONCE()\
67 { static bool was_here = false;\
70 OdAssert("Invalid Execution.", __FILE__, __LINE__);\
74 #define ODA_FAIL_M(message) (void)( (OdAssert(message, __FILE__, __LINE__), 0) )
75 #define ODA_FAIL_M_ONCE(message)\
76 { static bool was_here = false;\
79 OdAssert(message, __FILE__, __LINE__);\
84 #define ODA_ASSERT_X(grp, exp) (void)( (exp) || (OdAssert((const char*)#grp, (const char*)#exp, __FILE__, __LINE__), 0) )
85 #define ODA_VERIFY_X(grp, exp) ODA_ASSERT_X(grp, exp)
86 #define ODA_ASSERT_ONCE_X(grp, exp)\
87 { static bool was_here = false;\
88 if (!was_here && !(exp))\
90 OdAssert(#grp, #exp, __FILE__, __LINE__);\
93 #define ODA_FAIL_X(grp) OdAssert(#grp, "Invalid Execution.", __FILE__, __LINE__)
94 #define ODA_FAIL_ONCE_X(grp)\
95 { static bool was_here = false;\
98 OdAssert(#grp, "Invalid Execution.", __FILE__, __LINE__);\
101 #define ODA_ASSERT_VAR(code) code
102 #define ToOdInt8 (val) (ODA_ASSERT(( (OdInt8)val) == val), (OdInt8) val)
103 #define ToOdUInt8 (val) (ODA_ASSERT(( (OdUInt8)val) == val), (OdUInt8) val)
104 #define ToOdInt16 (val) (ODA_ASSERT((( OdInt16)val) == val), (OdInt16) val)
105 #define ToOdUInt16(val) (ODA_ASSERT(((OdUInt16)val) == val), (OdUInt16)val)
106 #define ToOdInt32 (val) (ODA_ASSERT(( (OdInt32)val) == val), (OdInt32) val)
107 #define ToOdUInt32(val) (ODA_ASSERT(((OdUInt32)val) == val), (OdUInt32)val)
111 #define ODA_ASSERT(condition)
112 #define ODA_VERIFY(condition) (void)(condition)
113 #define ODA_ASSERT_ONCE(condition)
114 #define ODA_VERIFY_ONCE(condition) (void)(condition)
116 #define ODA_FAIL_ONCE()
117 #define ODA_FAIL_M(message)
118 #define ODA_FAIL_M_ONCE(message)
120 #define ODA_ASSERT_X(grp, exp)
121 #define ODA_VERIFY_X(grp, exp) (void)(exp)
122 #define ODA_ASSERT_ONCE_X(grp, exp)
123 #define ODA_FAIL_X(grp)
124 #define ODA_FAIL_ONCE_X(grp)
125 #define ODA_ASSERT_VAR(code)
127 #define ToOdInt8 (val) ((OdInt8) val)
128 #define ToOdUInt8 (val) ((OdUInt8) val)
129 #define ToOdInt16 (val) ((OdInt16) val)
130 #define ToOdUInt16(val) ((OdUInt16)val)
131 #define ToOdInt32 (val) ((OdInt32) val)
132 #define ToOdUInt32(val) ((OdUInt32)val)
134 #define ODA_NON_TRACING
138 #ifndef ODA_NON_TRACING
139 #define ODA_TRACE OdTrace
140 #define ODA_TRACE0(szFormat) OdTrace(OD_T(szFormat))
141 #define ODA_TRACE1(szFormat, param1) OdTrace(OD_T(szFormat), param1)
142 #define ODA_TRACE2(szFormat, param1, param2) OdTrace(OD_T(szFormat), param1, param2)
143 #define ODA_TRACE3(szFormat, param1, param2, param3) OdTrace(OD_T(szFormat), param1, param2, param3)
146 #define ODA_TRACE0(szFormat)
147 #define ODA_TRACE1(szFormat, param1)
148 #define ODA_TRACE2(szFormat, param1, param2)
149 #define ODA_TRACE3(szFormat, param1, param2, param3)
155 #define ODA_ASSUME(expr) extern char __attribute((unused)) OdaAssumeArray[expr];
157 #define ODA_ASSUME(expr) extern char OdaAssumeArray[expr];
160 #if defined(_MSC_VER)
162 #pragma warning (push)
163 #pragma warning ( disable : 4100 )
164 #pragma warning ( disable : 4512 )
169 #if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) && (_MSC_VER >= 1200) && !defined(_ARM_)
174 inline void*
operator new(
size_t nSize,
const char* lpszFileName,
int nLine)
176 void* pRes = _malloc_dbg(nSize, _NORMAL_BLOCK, lpszFileName, nLine);
177 if(!pRes)
throw OdError(eOutOfMemory);
181 inline void operator delete(
void * pMem,
const char* ,
int )
183 _free_dbg(pMem, _NORMAL_BLOCK);
187 #define DEBUG_NEW new(__FILE__, __LINE__)
196 #pragma warning (pop)
207 #if defined(_MSC_VER)
208 #pragma warning (disable:4081)
210 #if defined(_MSC_VER) && defined(_DEBUG)
211 #define _schSTR(x) #x
212 #define _schSTR2(x) _schSTR(x)
213 #define MARKMESSAGE(desc) message(__FILE__ "(" _schSTR2(__LINE__) "): " #desc)
215 #if defined(__sun) && !defined(__GNUC__)
216 #define MARKMESSAGE(desc) dummy_pragma
218 #define MARKMESSAGE(desc)
223 #if defined(OD_DIAGNOSTICS) && defined(_MSC_VER) && defined(_DEBUG) && (_MSC_VER < 1400)
224 #pragma function(memcpy)
225 inline void * memcpy(
void * dest,
const void * src,
size_t size)
227 ODA_ASSERT(((
char*)dest > (
char*)src && (
char*)dest >= ((
char*)src +
size)) ||
228 ((
char*)dest < (
char*)src && ((
char*)dest +
size) <= (
char*)src) ||
230 return memmove(dest, src,
size);
235 #if defined(WIN32) || defined(_WIN32_WCE) || defined(__MWERKS__)
244 #if defined(__BORLANDC__) || defined(__BCPLUSPLUS__)
248 if (
x == 0. &&
y == 0.)
253 #elif defined(_DEBUG) && defined(_MSC_VER) && defined(ODA_LINT)
255 #define atan2(x, y) Do_not_use_atan2_directly__Use__OD_ATAN2_instead
258 #define OD_ATAN2(y,x) (atan2(y,x))
262 #if defined(ODA_LINT) && defined(_DEBUG)
264 #define asin(a) Do_not_use_asin_directly__Use__OD_ASIN_instead
267 #define acos(a) Do_not_use_acos_directly__Use__OD_ACOS_instead
269 #define OD_ASIN(a) asin(a)
270 #define OD_ACOS(a) acos(a)
274 #define OD_WARNING_PUSH warning(push)
275 #define OD_WARNING_DISABLE(number) warning(disable : number)
276 #define OD_WARNING_POP warning(pop)
277 #define OD_WARNING_SUPPRESS(number) warning(suppress : number)
279 #if defined(__sun) && !defined(__GNUC__)
280 #define OD_WARNING_PUSH dummy_pragma
281 #define OD_WARNING_DISABLE(number) dummy_pragma
282 #define OD_WARNING_POP dummy_pragma
283 #define OD_WARNING_SUPPRESS(number) dummy_pragma
285 #define OD_WARNING_PUSH
286 #define OD_WARNING_DISABLE(number)
287 #define OD_WARNING_POP
288 #define OD_WARNING_SUPPRESS(number)
void FIRSTDLL_EXPORT OdAssert(const char *expresssion, const char *filename, int nLineNo)
void FIRSTDLL_EXPORT OdTrace(const OdChar *szFormat,...)