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