Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
debug_macro.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
20// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/debug/debug_macro.h $
21// $Author: mhoffe $
22// $Revision: #2 $
23// $DateTime: 2003/07/09 10:57:23 $
24//
25// ©2003 Electronic Arts
26//
27// Debugging macros
29#ifdef _MSC_VER
30# pragma once
31#endif
32#ifndef DEBUG_MACRO_H // Include guard
33#define DEBUG_MACRO_H
34
35// I'm putting the documentation for the following macros
36// here because Doxygen otherwise includes the values of each macro
37// in the documentation. I don't want that (it would expose some
38// internals) so I'm putting all comments for the following macros
39// here...
40#ifdef DOXYGEN // defined if Doxygen is running
41
52
64 #define DASSERT(expr)
65
82 #define DASSERT_MSG(expr,msg)
83
104 #define DCTASSERT(expr)
105
119 #define DCHECK(expr)
120
132 #define DCHECK_MSG(expr,msg)
133
148 #define DFAIL_IF(cond)
149
165 #define DFAIL_IF_MSG(cond,msg)
166
178 #define DLOG(what)
179
186 #define DLOG_DESCR(descr)
187
202 #define DLOG_GROUP(group,what)
203
211 #define DLOG_GROUP_DESCR(group,descr)
212
220 #define DCRASH(msg)
221
230 #define DCRASH_RELEASE(msg)
231
252 #define DFAIL()
253
270 #define D_ISLOG()
271
281 #define D_ISLOG_GROUP(group)
282
284
285#elif defined(_DEBUG) || defined(_INTERNAL)
286
287 #define DASSERT(expr) \
288 ((void)( Debug::SkipNext() || \
289 (expr) || \
290 Debug::AssertBegin(__FILE__,__LINE__,#expr).AssertDone() ))
291
292 #define DASSERT_MSG(expr,msg) \
293 ((void)( Debug::SkipNext() || \
294 (expr) || \
295 ( Debug::AssertBegin(__FILE__,__LINE__,#expr) << ": " << msg ).AssertDone() ))
296
297 #define DCHECK(expr) \
298 ( (expr) || \
299 Debug::SkipNext() || \
300 Debug::CheckBegin(__FILE__,__LINE__,#expr).CheckDone() )
301
302 #define DCHECK_MSG(expr,msg) \
303 ( (expr) || \
304 Debug::SkipNext() || \
305 ( Debug::CheckBegin(__FILE__,__LINE__,#expr) << ": " << msg ).CheckDone() )
306
307 #define DFAIL_IF(cond) \
308 if (!DCHECK(!(cond)))
309
310 #define DFAIL_IF_MSG(cond,msg) \
311 if (!DCHECK_MSG(!(cond),msg))
312
313 #define DLOG(what) \
314 ((void)( Debug::SkipNext() || \
315 ( Debug::LogBegin(__FILE__) << what ).LogDone() ))
316
317 #define DLOG_DESCR(descr) \
318 static Debug::LogDescription _LogDescr_FILE(__FILE__,descr);
319
320 #define DLOG_GROUP(group,what) \
321 ((void)( Debug::SkipNext() || \
322 ( Debug::LogBegin(#group) << what ).LogDone() ))
323
324 #define DLOG_GROUP_DESCR(group,descr) \
325 static Debug::LogDescription(#group,descr) _LogDescr_Grp_##group
326
327 #define DCRASH(msg) \
328 (Debug::SkipNext() || (Debug::CrashBegin(__FILE__,__LINE__) << msg).CrashDone(false))
329
330 #define DCRASH_RELEASE(msg) \
331 (Debug::SkipNext(),(Debug::CrashBegin(__FILE__,__LINE__) << msg).CrashDone(true))
332
333 #define DFAIL() \
334 Debug::AssertBegin(__FILE__,__LINE__,NULL).AssertDone()
335
336 #define D_ISLOG() \
337 Debug::IsLogEnabled(__FILE__)
338
339 #define D_ISLOG_GROUP(group) \
340 Debug::IsLogEnabled(#group)
341
342#else
343
344 #define DASSERT(expr) ((void)0)
345 #define DASSERT_MSG(expr,msg) ((void)0)
346 #define DCHECK(expr) (expr)
347 #define DCHECK_MSG(expr,msg) (expr)
348 #define DFAIL_IF(cond) if (cond)
349 #define DFAIL_IF_MSG(cond,msg) if (cond)
350 #define DLOG(what) ((void)0)
351 #define DLOG_DESCR(descr)
352 #define DLOG_GROUP(group,what) ((void)0)
353 #define DLOG_GROUP_DESCR(g,d)
354 #define DCRASH(msg) ((void)0)
355 #define DCRASH_RELEASE(msg) (Debug::SkipNext(),(Debug::CrashBegin(NULL,0) << msg).CrashDone(true))
356 #define DFAIL() ((void)0)
357 #define D_ISLOG() false
358 #define D_ISLOG_GROUP(group) false
359
360#endif
361
362// put these helper templates in a namespace...
363namespace _Debug
364{
365 template<bool> struct StaticAssertionFailed;
366 template<> struct StaticAssertionFailed<true> {};
367 template<int x> struct StaticAssertionTest {};
368
369 #define DCTASSERT(expr) typedef ::_Debug::StaticAssertionTest< \
370 sizeof(::_Debug::StaticAssertionFailed< (bool)(expr) >) \
371 > DebugStaticAssertTypedef__;
372};
373
374// These are stolen from the WW3D Debug file. REALLY useful. :-)
375#define STRING_IT(a) #a
376#define TOKEN_IT(a) STRING_IT(,##a)
377
392#define MESSAGE(a) message (__FILE__ "(" TOKEN_IT(__LINE__) ") : " a)
393
394#endif // DEBUG_MACRO_H
@ true
Definition bool.h:59