config.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef CMARK_CONFIG_H
  2. #define CMARK_CONFIG_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #define HAVE_STDBOOL_H
  7. #ifdef HAVE_STDBOOL_H
  8. #include <stdbool.h>
  9. #elif !defined(__cplusplus)
  10. typedef char bool;
  11. #endif
  12. #define HAVE___BUILTIN_EXPECT
  13. #define HAVE___ATTRIBUTE__
  14. #ifdef HAVE___ATTRIBUTE__
  15. #define CMARK_ATTRIBUTE(list) __attribute__ (list)
  16. #else
  17. #define CMARK_ATTRIBUTE(list)
  18. #endif
  19. #ifndef CMARK_INLINE
  20. #if defined(_MSC_VER) && !defined(__cplusplus)
  21. #define CMARK_INLINE __inline
  22. #else
  23. #define CMARK_INLINE inline
  24. #endif
  25. #endif
  26. /* snprintf and vsnprintf fallbacks for MSVC before 2015,
  27. due to Valentin Milea http://stackoverflow.com/questions/2915672/
  28. */
  29. #if defined(_MSC_VER) && _MSC_VER < 1900
  30. #include <stdio.h>
  31. #include <stdarg.h>
  32. #define snprintf c99_snprintf
  33. #define vsnprintf c99_vsnprintf
  34. CMARK_INLINE int c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
  35. {
  36. int count = -1;
  37. if (size != 0)
  38. count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
  39. if (count == -1)
  40. count = _vscprintf(format, ap);
  41. return count;
  42. }
  43. CMARK_INLINE int c99_snprintf(char *outBuf, size_t size, const char *format, ...)
  44. {
  45. int count;
  46. va_list ap;
  47. va_start(ap, format);
  48. count = c99_vsnprintf(outBuf, size, format, ap);
  49. va_end(ap);
  50. return count;
  51. }
  52. #endif
  53. #ifdef __cplusplus
  54. }
  55. #endif
  56. #endif