From 0c8c16a44a1d56e6fd5652657e8b6b2c6e478bfc Mon Sep 17 00:00:00 2001 From: q66 Date: Wed, 6 Jul 2016 17:05:32 +0100 Subject: [PATCH] windows fixes + stdin/stdout/stderr might be defined as macros --- ostd/io.hh | 18 +++++++++--------- ostd/types.hh | 13 +++++++++++++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/ostd/io.hh b/ostd/io.hh index be32039..d29ef99 100644 --- a/ostd/io.hh +++ b/ostd/io.hh @@ -124,9 +124,9 @@ private: bool p_owned; }; -static FileStream in(::stdin); -static FileStream out(::stdout); -static FileStream err(::stderr); +static FileStream in(stdin); +static FileStream out(stdout); +static FileStream err(stderr); /* no need to call anything from FileStream, prefer simple calls... */ @@ -134,7 +134,7 @@ namespace detail { struct IoNat {}; inline void write_impl(ConstCharRange s) { - fwrite(&s[0], 1, s.size(), ::stdout); + fwrite(&s[0], 1, s.size(), stdout); } template @@ -159,14 +159,14 @@ inline void write(T const &v, A const &...args) { template inline void writeln(T const &v) { write(v); - putc('\n', ::stdout); + putc('\n', stdout); } template inline void writeln(T const &v, A const &...args) { write(v); write(args...); - putc('\n', ::stdout); + putc('\n', stdout); } template @@ -176,19 +176,19 @@ inline void writef(ConstCharRange fmt, A const &...args) { fmt, args...); if (need < 0) return; else if (Size(need) < sizeof(buf)) { - fwrite(buf, 1, need, ::stdout); + fwrite(buf, 1, need, stdout); return; } Vector s; s.reserve(need); format(detail::UnsafeWritefRange(s.data()), fmt, args...); - fwrite(s.data(), 1, need, ::stdout); + fwrite(s.data(), 1, need, stdout); } template inline void writefln(ConstCharRange fmt, A const &...args) { writef(fmt, args...); - putc('\n', ::stdout); + putc('\n', stdout); } } /* namespace ostd */ diff --git a/ostd/types.hh b/ostd/types.hh index 6bb636a..7c197f2 100644 --- a/ostd/types.hh +++ b/ostd/types.hh @@ -26,8 +26,21 @@ using ldouble = long double; /* keywords in c++, but aliased */ using Wchar = wchar_t; + +/* while we do not support Visual Studio 2013, Clang on Windows by default + * pretends to be VS (with the default version being 2013). In this case, + * it also tries to be compatible (in order to not conflict with MS include + * headers) with said version, so it doesn't provide the builtins; so we work + * around this (same typedefs/behavior as VS 2013, of course not standards + * compliant but no way around it) + */ +#if defined(_MSC_VER) && (_MSC_VER < 1900) +using Char16 = uint16_t; +using Char32 = uint32_t; +#else using Char16 = char16_t; using Char32 = char32_t; +#endif /* nullptr type */