trace.cpp 612 B

1234567891011121314151617181920212223242526
  1. // trace.cpp -- debugging print function
  2. //
  3. // (I think this was created to provide a generic print function
  4. // for use in non-command-line Windows applications where printf
  5. // does not work. Currently, it is not used, but kept around for
  6. // possible debugging needs. -RBD)
  7. #include "stdarg.h"
  8. #include "stdio.h"
  9. #include "crtdbg.h"
  10. void trace(char *format, ...)
  11. {
  12. char msg[256];
  13. va_list args;
  14. va_start(args, format);
  15. _vsnprintf_s(msg, 256, _TRUNCATE, format, args);
  16. va_end(args);
  17. #ifdef _DEBUG
  18. _CrtDbgReport(_CRT_WARN, nullptr, nullptr, nullptr, msg);
  19. #else
  20. printf(msg);
  21. #endif
  22. }