verbose.h 633 B

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