2
0

win32.h 744 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef _WIN32_HELPER_INCLUDE
  2. #define _WIN32_HELPER_INCLUDE
  3. #ifdef _MSC_VER
  4. #ifndef inline
  5. #define inline __inline
  6. #endif
  7. #ifndef va_copy
  8. #define va_copy(d,s) ((d) = (s))
  9. #endif
  10. #ifndef snprintf
  11. #define snprintf c99_snprintf
  12. __inline int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap)
  13. {
  14. int count = -1;
  15. if (size != 0)
  16. count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
  17. if (count == -1)
  18. count = _vscprintf(format, ap);
  19. return count;
  20. }
  21. __inline int c99_snprintf(char* str, size_t size, const char* format, ...)
  22. {
  23. int count;
  24. va_list ap;
  25. va_start(ap, format);
  26. count = c99_vsnprintf(str, size, format, ap);
  27. va_end(ap);
  28. return count;
  29. }
  30. #endif
  31. #endif
  32. #endif