debug.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. ** Command & Conquer Generals(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. // FILE: debug.h //////////////////////////////////////////////////////////////
  19. // Minimal debug info
  20. // Author: Matthew D. Campbell, Sept 2002
  21. #ifndef __DEBUG_H__
  22. #define __DEBUG_H__
  23. #ifdef DEBUG
  24. #include <cstdarg>
  25. void DebugLog( const char *fmt, ... );
  26. #define DEBUG_LOG(x) DebugLog x
  27. #else // DEBUG
  28. #define DEBUG_LOG(x) {}
  29. #endif // DEBUG
  30. #ifdef DEBUG_CRASHING
  31. extern void DebugCrash(const char *format, ...);
  32. /*
  33. Yeah, it's a sleazy global, since we can't reasonably add
  34. any args to DebugCrash due to the varargs nature of it.
  35. We'll just let it slide in this case...
  36. */
  37. extern char* TheCurrentIgnoreCrashPtr;
  38. #define DEBUG_CRASH(m) \
  39. do { \
  40. { \
  41. static char ignoreCrash = 0; \
  42. if (!ignoreCrash) { \
  43. TheCurrentIgnoreCrashPtr = &ignoreCrash; \
  44. DebugCrash m ; \
  45. TheCurrentIgnoreCrashPtr = NULL; \
  46. } \
  47. } \
  48. } while (0)
  49. #define DEBUG_ASSERTCRASH(c, m) do { { if (!(c)) DEBUG_CRASH(m); } } while (0)
  50. #else
  51. #define DEBUG_CRASH(m) ((void)0)
  52. #define DEBUG_ASSERTCRASH(c, m) ((void)0)
  53. #endif
  54. #endif // __DEBUG_H__