diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h index 58d5be27417..db312f87358 100644 --- a/include/llvm/Support/raw_ostream.h +++ b/include/llvm/Support/raw_ostream.h @@ -17,6 +17,7 @@ #include "llvm/ADT/StringExtras.h" #include #include +#include #include #include @@ -173,7 +174,11 @@ public: /// returns the length of the formatted string. If the buffer is too small, /// this returns a length to retry with, which will be larger than BufferSize. virtual unsigned print(char *Buffer, unsigned BufferSize) const { +#ifdef WIN32 + int N = _snprintf(Buffer, BufferSize-1, Fmt, Val); +#else int N = snprintf(Buffer, BufferSize-1, Fmt, Val); +#endif if (N < 0) // VC++ and old GlibC return negative on overflow. return BufferSize*2; if (unsigned(N) >= BufferSize-1)// Other impls yield number of bytes needed.