verbose.h 582 B

12345678910111213141516171819202122232425262728
  1. // Provide a macro for printf, called verbose that functions exactly like
  2. // printf if VERBOSE is defined and does exactly nothing if VERBOSE is
  3. // undefined
  4. #include <cstdio>
  5. #ifdef VERBOSE
  6. # include <cstdarg>
  7. #endif
  8. namespace igl
  9. {
  10. inline int verbose(const char * msg,...);
  11. };
  12. // Implementation
  13. // http://channel9.msdn.com/forums/techoff/254707-wrapping-printf-in-c/
  14. inline int igl::verbose(const char * msg,...)
  15. {
  16. #ifdef VERBOSE
  17. va_list argList;
  18. va_start(argList, msg);
  19. int count = vprintf(msg, argList);
  20. va_end(argList);
  21. return count;
  22. #else
  23. return 0;
  24. #endif
  25. }