DownloadDebug.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. // DownloadDebug.h
  19. #ifndef __DOWNLOADDEBUG_H_
  20. #define __DOWNLOADDEBUG_H_
  21. #ifdef NDEBUG
  22. #define DEBUG_LOG(exp) ((void)0)
  23. #else
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #include <stdarg.h>
  28. extern void DebugCrash( const char *fmt, ... );
  29. extern void DebugLog( const char *fmt, ... );
  30. /*
  31. Yeah, it's a sleazy global, since we can't reasonably add
  32. any args to DebugCrash due to the varargs nature of it.
  33. We'll just let it slide in this case...
  34. */
  35. extern char* TheCurrentIgnoreCrashPtr;
  36. #define DEBUG_CRASH(m) \
  37. do { \
  38. { \
  39. static char ignoreCrash = 0; \
  40. if (!ignoreCrash) { \
  41. TheCurrentIgnoreCrashPtr = &ignoreCrash; \
  42. DebugCrash m ; \
  43. TheCurrentIgnoreCrashPtr = NULL; \
  44. } \
  45. } \
  46. } while (0)
  47. #define DEBUG_LOG(x) do { DebugLog x; } while (0)
  48. #define DEBUG_ASSERTCRASH(c, m) do { { if (!(c)) DEBUG_CRASH(m); } } while (0)
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #endif // NDEBUG
  53. #endif //__DOWNLOADDEBUG_H_