diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-10-29 12:45:13 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-10-29 12:45:13 -0700 |
commit | ece9ebc81b7011beba27a48bd723046392e34147 (patch) | |
tree | 68391ca6fdaace5024eda46bb58a623ee1ea4ed4 /src/snprintf.h | |
parent | b3b8d931068ff09e245233451b4f1d47648f1e2b (diff) | |
download | binaryen-ece9ebc81b7011beba27a48bd723046392e34147.tar.gz binaryen-ece9ebc81b7011beba27a48bd723046392e34147.tar.bz2 binaryen-ece9ebc81b7011beba27a48bd723046392e34147.zip |
add missing headers
Diffstat (limited to 'src/snprintf.h')
-rw-r--r-- | src/snprintf.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/snprintf.h b/src/snprintf.h new file mode 100644 index 000000000..2792a23a2 --- /dev/null +++ b/src/snprintf.h @@ -0,0 +1,32 @@ +#include <stdarg.h> + +// Visual Studio does not support C99, so emulate snprintf support for it manually. + +#ifdef _MSC_VER + +#define snprintf c99_snprintf + +inline int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap) +{ + int count = -1; + + if (size != 0) + count = _vsnprintf_s(str, size, _TRUNCATE, format, ap); + if (count == -1) + count = _vscprintf(format, ap); + + return count; +} + +inline int c99_snprintf(char* str, size_t size, const char* format, ...) +{ + int count; + va_list ap; + + va_start(ap, format); + count = c99_vsnprintf(str, size, format, ap); + va_end(ap); + + return count; +} +#endif |