27#ifndef __DEBUG_STUFF__INCLUDED
28#define __DEBUG_STUFF__INCLUDED
31#if defined(_DEBUG) || !defined(NDEBUG)
32#define ODA_DIAGNOSTICS
42 const char* expresssion,
const char* fileName,
int nLineNo);
44#if defined(_MSC_VER) && _MSC_VER >= 1300
50#define ODA_ASSERT(exp) \
51_Pragma("clang diagnostic push") \
52_Pragma("clang diagnostic ignored \"-Wunused-value\" ") \
53_Pragma("clang diagnostic ignored \"-Wpointer-bool-conversion\" ") \
54((!(exp)) ? OdAssert(#exp, __FILE__, __LINE__) : oda_noop()) \
55_Pragma("clang diagnostic pop")
57#define ODA_ASSERT(exp) ((!(exp)) ? OdAssert(#exp, __FILE__, __LINE__) : oda_noop())
59#define ODA_VERIFY(exp) ODA_ASSERT(exp)
61#define ODA_ASSERT_ONCE(exp)\
62_Pragma("clang diagnostic push") \
63_Pragma("clang diagnostic ignored \"-Wunused-value\" ") \
64_Pragma("clang diagnostic ignored \"-Wpointer-bool-conversion\" ") \
65{ static bool was_here = false;\
66 if (!was_here && !(exp))\
68 OdAssert(#exp, __FILE__, __LINE__);\
71_Pragma("clang diagnostic pop")
73#define ODA_ASSERT_ONCE(exp)\
74{ static bool was_here = false;\
75 if (!was_here && !(exp))\
77 OdAssert(#exp, __FILE__, __LINE__);\
81#define ODA_VERIFY_ONCE(exp)\
82{ static bool was_here = false;\
83 if (!(exp) && !was_here)\
85 OdAssert(#exp, __FILE__, __LINE__);\
88#define ODA_FAIL() OdAssert("Invalid Execution.", __FILE__, __LINE__)
89#define ODA_FAIL_ONCE()\
90{ static bool was_here = false;\
93 OdAssert("Invalid Execution.", __FILE__, __LINE__);\
97#define ODA_FAIL_M(message) (void)( (OdAssert(message, __FILE__, __LINE__), 0) )
98#define ODA_FAIL_M_ONCE(message)\
99{ static bool was_here = false;\
102 OdAssert(message, __FILE__, __LINE__);\
107#define ODA_ASSERT_X(grp, exp) (void)( (exp) || (OdAssert((const char*)#grp, (const char*)#exp, __FILE__, __LINE__), 0) )
108#define ODA_VERIFY_X(grp, exp) ODA_ASSERT_X(grp, exp)
109#define ODA_ASSERT_ONCE_X(grp, exp)\
110{ static bool was_here = false;\
111 if (!was_here && !(exp))\
113 OdAssert(#grp, #exp, __FILE__, __LINE__);\
116#define ODA_FAIL_X(grp) OdAssert(#grp, "Invalid Execution.", __FILE__, __LINE__)
117#define ODA_FAIL_ONCE_X(grp)\
118{ static bool was_here = false;\
121 OdAssert(#grp, "Invalid Execution.", __FILE__, __LINE__);\
124#define ODA_ASSERT_VAR(code) code
125#define ToOdInt8 (val) (ODA_ASSERT(( (OdInt8)val) == val), (OdInt8) val)
126#define ToOdUInt8 (val) (ODA_ASSERT(( (OdUInt8)val) == val), (OdUInt8) val)
127#define ToOdInt16 (val) (ODA_ASSERT((( OdInt16)val) == val), (OdInt16) val)
128#define ToOdUInt16(val) (ODA_ASSERT(((OdUInt16)val) == val), (OdUInt16)val)
129#define ToOdInt32 (val) (ODA_ASSERT(( (OdInt32)val) == val), (OdInt32) val)
130#define ToOdUInt32(val) (ODA_ASSERT(((OdUInt32)val) == val), (OdUInt32)val)
134#define ODA_ASSERT(condition)
135#define ODA_VERIFY(condition) (void)(condition)
136#define ODA_ASSERT_ONCE(condition)
137#define ODA_VERIFY_ONCE(condition) (void)(condition)
139#define ODA_FAIL_ONCE()
140#define ODA_FAIL_M(message)
141#define ODA_FAIL_M_ONCE(message)
143#define ODA_ASSERT_X(grp, exp)
144#define ODA_VERIFY_X(grp, exp) (void)(exp)
145#define ODA_ASSERT_ONCE_X(grp, exp)
146#define ODA_FAIL_X(grp)
147#define ODA_FAIL_ONCE_X(grp)
148#define ODA_ASSERT_VAR(code)
150#define ToOdInt8 (val) ((OdInt8) val)
151#define ToOdUInt8 (val) ((OdUInt8) val)
152#define ToOdInt16 (val) ((OdInt16) val)
153#define ToOdUInt16(val) ((OdUInt16)val)
154#define ToOdInt32 (val) ((OdInt32) val)
155#define ToOdUInt32(val) ((OdUInt32)val)
157#define ODA_NON_TRACING
161#ifndef ODA_NON_TRACING
162 #define ODA_TRACE OdTrace
163 #define ODA_TRACE0(szFormat) OdTrace(OD_T(szFormat))
164 #define ODA_TRACE1(szFormat, param1) OdTrace(OD_T(szFormat), param1)
165 #define ODA_TRACE2(szFormat, param1, param2) OdTrace(OD_T(szFormat), param1, param2)
166 #define ODA_TRACE3(szFormat, param1, param2, param3) OdTrace(OD_T(szFormat), param1, param2, param3)
169 #define ODA_TRACE0(szFormat)
170 #define ODA_TRACE1(szFormat, param1)
171 #define ODA_TRACE2(szFormat, param1, param2)
172 #define ODA_TRACE3(szFormat, param1, param2, param3)
178 #define ODA_ASSUME(expr) extern char __attribute((unused)) OdaAssumeArray[expr];
180 #define ODA_ASSUME(expr) extern char OdaAssumeArray[expr];
185#pragma warning (push)
186#pragma warning ( disable : 4100 )
187#pragma warning ( disable : 4512 )
192#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) && (_MSC_VER >= 1200) && !defined(_ARM_)
197inline void*
operator new(
size_t nSize,
const char* lpszFileName,
int nLine)
199 void* pRes = _malloc_dbg(nSize, _NORMAL_BLOCK, lpszFileName, nLine);
200 if(!pRes)
throw OdError(eOutOfMemory);
204inline void operator delete(
void * pMem,
const char* ,
int )
206 _free_dbg(pMem, _NORMAL_BLOCK);
210#define DEBUG_NEW new(__FILE__, __LINE__)
230 #if defined(_MSC_VER)
231 #pragma warning (disable:4081)
233 #if defined(_MSC_VER) && defined(_DEBUG)
234 #define _schSTR(x) #x
235 #define _schSTR2(x) _schSTR(x)
236 #define MARKMESSAGE(desc) message(__FILE__ "(" _schSTR2(__LINE__) "): " #desc)
238 #if defined(__sun) && !defined(__GNUC__)
239 #define MARKMESSAGE(desc) dummy_pragma
241 #define MARKMESSAGE(desc)
246#if defined(OD_DIAGNOSTICS) && defined(_MSC_VER) && defined(_DEBUG) && (_MSC_VER < 1400)
247#pragma function(memcpy)
248inline void * memcpy(
void * dest,
const void * src,
size_t size)
250 ODA_ASSERT(((
char*)dest > (
char*)src && (
char*)dest >= ((
char*)src +
size)) ||
251 ((
char*)dest < (
char*)src && ((
char*)dest +
size) <= (
char*)src) ||
253 return memmove(dest, src,
size);
258#if defined(WIN32) || defined(_WIN32_WCE) || defined(__MWERKS__)
267#if defined(__BORLANDC__) || defined(__BCPLUSPLUS__)
271 if (
x == 0. &&
y == 0.)
276#elif defined(_DEBUG) && defined(ODA_LINT) && (!defined(_MSC_VER) || (defined(_MSC_VER) && (_MSC_VER < 1920)))
278 #define atan2(x, y) Do_not_use_atan2_directly__Use__OD_ATAN2_instead
281 #define OD_ATAN2(y,x) (atan2(y,x))
285#if defined(ODA_LINT) && defined(_DEBUG) && (_MSC_VER < 1920)
287 #define asin(a) Do_not_use_asin_directly__Use__OD_ASIN_instead
290 #define acos(a) Do_not_use_acos_directly__Use__OD_ACOS_instead
292#define OD_ASIN(a) asin(a)
293#define OD_ACOS(a) acos(a)
297#define OD_WARNING_PUSH warning(push)
298#define OD_WARNING_DISABLE(number) warning(disable : number)
299#define OD_WARNING_POP warning(pop)
300#define OD_WARNING_SUPPRESS(number) warning(suppress : number)
302 #if defined(__sun) && !defined(__GNUC__)
303 #define OD_WARNING_PUSH dummy_pragma
304 #define OD_WARNING_DISABLE(number) dummy_pragma
305 #define OD_WARNING_POP dummy_pragma
306 #define OD_WARNING_SUPPRESS(number) dummy_pragma
308 #define OD_WARNING_PUSH
309 #define OD_WARNING_DISABLE(number)
310 #define OD_WARNING_POP
311 #define OD_WARNING_SUPPRESS(number)
void FIRSTDLL_EXPORT OdAssert(const char *expresssion, const char *filename, int nLineNo)
void FIRSTDLL_EXPORT OdTrace(const OdChar *szFormat,...)