Improve naming consistency

This commit is contained in:
Victor Zverovich 2018-05-19 08:57:31 -07:00
parent d940fa679c
commit 69823bf852
12 changed files with 95 additions and 92 deletions

View File

@ -113,14 +113,14 @@ int safe_strerror(
int error_code, char *&buffer, std::size_t buffer_size) FMT_NOEXCEPT {
FMT_ASSERT(buffer != FMT_NULL && buffer_size != 0, "invalid buffer");
class StrError {
class dispatcher {
private:
int error_code_;
char *&buffer_;
std::size_t buffer_size_;
// A noop assignment operator to avoid bogus warnings.
void operator=(const StrError &) {}
void operator=(const dispatcher &) {}
// Handle the result of XSI-compliant version of strerror_r.
int handle(int result) {
@ -157,14 +157,14 @@ int safe_strerror(
}
public:
StrError(int err_code, char *&buf, std::size_t buf_size)
dispatcher(int err_code, char *&buf, std::size_t buf_size)
: error_code_(err_code), buffer_(buf), buffer_size_(buf_size) {}
int run() {
return handle(strerror_r(error_code_, buffer_, buffer_size_));
}
};
return StrError(error_code, buffer, buffer_size).run();
return dispatcher(error_code, buffer, buffer_size).run();
}
void format_error_code(internal::buffer &out, int error_code,

View File

@ -2974,7 +2974,7 @@ FMT_API void report_windows_error(int error_code,
#endif
/** Fast integer formatter. */
class FormatInt {
class format_int {
private:
// Buffer should be large enough to hold all digits (digits10 + 1),
// a sign and a null character.
@ -3015,12 +3015,12 @@ class FormatInt {
}
public:
explicit FormatInt(int value) { format_signed(value); }
explicit FormatInt(long value) { format_signed(value); }
explicit FormatInt(long long value) { format_signed(value); }
explicit FormatInt(unsigned value) : str_(format_decimal(value)) {}
explicit FormatInt(unsigned long value) : str_(format_decimal(value)) {}
explicit FormatInt(unsigned long long value) : str_(format_decimal(value)) {}
explicit format_int(int value) { format_signed(value); }
explicit format_int(long value) { format_signed(value); }
explicit format_int(long long value) { format_signed(value); }
explicit format_int(unsigned value) : str_(format_decimal(value)) {}
explicit format_int(unsigned long value) : str_(format_decimal(value)) {}
explicit format_int(unsigned long long value) : str_(format_decimal(value)) {}
/** Returns the number of characters written to the output buffer. */
std::size_t size() const {
@ -3647,7 +3647,7 @@ FMT_END_NAMESPACE
#include <fmt/format.h>
// A compile-time error because 'd' is an invalid specifier for strings.
std::string s = fmt::format(fmt("{:d}"), "foo");
std::string s = format(fmt("{:d}"), "foo");
\endrst
*/
# define fmt(s) FMT_STRING(s)

View File

@ -15,7 +15,7 @@ FMT_BEGIN_NAMESPACE
namespace internal {
template <class Char>
class FormatBuf : public std::basic_streambuf<Char> {
class formatbuf : public std::basic_streambuf<Char> {
private:
typedef typename std::basic_streambuf<Char>::int_type int_type;
typedef typename std::basic_streambuf<Char>::traits_type traits_type;
@ -23,7 +23,7 @@ class FormatBuf : public std::basic_streambuf<Char> {
basic_buffer<Char> &buffer_;
public:
FormatBuf(basic_buffer<Char> &buffer) : buffer_(buffer) {}
formatbuf(basic_buffer<Char> &buffer) : buffer_(buffer) {}
protected:
// The put-area is actually always empty. This makes the implementation
@ -90,7 +90,7 @@ void write(std::basic_ostream<Char> &os, basic_buffer<Char> &buf) {
template <typename Char, typename T>
void format_value(basic_buffer<Char> &buffer, const T &value) {
internal::FormatBuf<Char> format_buf(buffer);
internal::formatbuf<Char> format_buf(buffer);
std::basic_ostream<Char> output(&format_buf);
output.exceptions(std::ios_base::failbit | std::ios_base::badbit);
output << value;

View File

@ -124,20 +124,20 @@ class ErrorCode {
};
// A buffered file.
class BufferedFile {
class buffered_file {
private:
FILE *file_;
friend class File;
explicit BufferedFile(FILE *f) : file_(f) {}
explicit buffered_file(FILE *f) : file_(f) {}
public:
// Constructs a BufferedFile object which doesn't represent any file.
BufferedFile() FMT_NOEXCEPT : file_(FMT_NULL) {}
// Constructs a buffered_file object which doesn't represent any file.
buffered_file() FMT_NOEXCEPT : file_(FMT_NULL) {}
// Destroys the object closing the file it represents if any.
FMT_API ~BufferedFile() FMT_DTOR_NOEXCEPT;
FMT_API ~buffered_file() FMT_DTOR_NOEXCEPT;
#if !FMT_USE_RVALUE_REFERENCES
// Emulate a move constructor and a move assignment operator if rvalue
@ -152,22 +152,22 @@ class BufferedFile {
public:
// A "move constructor" for moving from a temporary.
BufferedFile(Proxy p) FMT_NOEXCEPT : file_(p.file) {}
buffered_file(Proxy p) FMT_NOEXCEPT : file_(p.file) {}
// A "move constructor" for moving from an lvalue.
BufferedFile(BufferedFile &f) FMT_NOEXCEPT : file_(f.file_) {
buffered_file(buffered_file &f) FMT_NOEXCEPT : file_(f.file_) {
f.file_ = FMT_NULL;
}
// A "move assignment operator" for moving from a temporary.
BufferedFile &operator=(Proxy p) {
buffered_file &operator=(Proxy p) {
close();
file_ = p.file;
return *this;
}
// A "move assignment operator" for moving from an lvalue.
BufferedFile &operator=(BufferedFile &other) {
buffered_file &operator=(buffered_file &other) {
close();
file_ = other.file_;
other.file_ = FMT_NULL;
@ -175,7 +175,7 @@ public:
}
// Returns a proxy object for moving from a temporary:
// BufferedFile file = BufferedFile(...);
// buffered_file file = buffered_file(...);
operator Proxy() FMT_NOEXCEPT {
Proxy p = {file_};
file_ = FMT_NULL;
@ -184,14 +184,14 @@ public:
#else
private:
FMT_DISALLOW_COPY_AND_ASSIGN(BufferedFile);
FMT_DISALLOW_COPY_AND_ASSIGN(buffered_file);
public:
BufferedFile(BufferedFile &&other) FMT_NOEXCEPT : file_(other.file_) {
buffered_file(buffered_file &&other) FMT_NOEXCEPT : file_(other.file_) {
other.file_ = FMT_NULL;
}
BufferedFile& operator=(BufferedFile &&other) {
buffered_file& operator=(buffered_file &&other) {
close();
file_ = other.file_;
other.file_ = FMT_NULL;
@ -200,7 +200,7 @@ public:
#endif
// Opens a file.
FMT_API BufferedFile(cstring_view filename, cstring_view mode);
FMT_API buffered_file(cstring_view filename, cstring_view mode);
// Closes the file.
FMT_API void close();
@ -344,9 +344,9 @@ class File {
// and writing respectively.
FMT_API static void pipe(File &read_end, File &write_end);
// Creates a BufferedFile object associated with this file and detaches
// Creates a buffered_file object associated with this file and detaches
// this File object from the file.
FMT_API BufferedFile fdopen(const char *mode);
FMT_API buffered_file fdopen(const char *mode);
};
// Returns the memory page size.
@ -409,7 +409,7 @@ FMT_END_NAMESPACE
#if !FMT_USE_RVALUE_REFERENCES
namespace std {
// For compatibility with C++98.
inline fmt::BufferedFile &move(fmt::BufferedFile &f) { return f; }
inline fmt::buffered_file &move(fmt::buffered_file &f) { return f; }
inline fmt::File &move(fmt::File &f) { return f; }
}
#endif

View File

@ -22,11 +22,11 @@ inline null<> gmtime_s(...) { return null<>(); }
// Thread-safe replacement for std::localtime
inline std::tm localtime(std::time_t time) {
struct LocalTime {
struct dispatcher {
std::time_t time_;
std::tm tm_;
LocalTime(std::time_t t): time_(t) {}
dispatcher(std::time_t t): time_(t) {}
bool run() {
using namespace fmt::internal;
@ -49,7 +49,7 @@ inline std::tm localtime(std::time_t time) {
return tm != FMT_NULL;
}
};
LocalTime lt(time);
dispatcher lt(time);
if (lt.run())
return lt.tm_;
// Too big time values may be unsupported.
@ -59,11 +59,11 @@ inline std::tm localtime(std::time_t time) {
// Thread-safe replacement for std::gmtime
inline std::tm gmtime(std::time_t time) {
struct GMTime {
struct dispatcher {
std::time_t time_;
std::tm tm_;
GMTime(std::time_t t): time_(t) {}
dispatcher(std::time_t t): time_(t) {}
bool run() {
using namespace fmt::internal;
@ -85,7 +85,7 @@ inline std::tm gmtime(std::time_t time) {
return tm != FMT_NULL;
}
};
GMTime gt(time);
dispatcher gt(time);
if (gt.run())
return gt.tm_;
// Too big time values may be unsupported.
@ -94,11 +94,13 @@ inline std::tm gmtime(std::time_t time) {
}
namespace internal {
inline std::size_t strftime(char *str, std::size_t count, const char *format, const std::tm *time) {
inline std::size_t strftime(char *str, std::size_t count, const char *format,
const std::tm *time) {
return std::strftime(str, count, format, time);
}
inline std::size_t strftime(wchar_t *str, std::size_t count, const wchar_t *format, const std::tm *time) {
inline std::size_t strftime(wchar_t *str, std::size_t count,
const wchar_t *format, const std::tm *time) {
return std::wcsftime(str, count, format, time);
}
}
@ -126,7 +128,8 @@ struct formatter<std::tm, Char> {
std::size_t start = buf.size();
for (;;) {
std::size_t size = buf.capacity() - start;
std::size_t count = internal::strftime(&buf[start], size, &tm_format[0], &tm);
std::size_t count =
internal::strftime(&buf[start], size, &tm_format[0], &tm);
if (count != 0) {
buf.resize(start + count);
break;

View File

@ -66,19 +66,19 @@ inline std::size_t convert_rwcount(std::size_t count) { return count; }
FMT_BEGIN_NAMESPACE
BufferedFile::~BufferedFile() FMT_NOEXCEPT {
buffered_file::~buffered_file() FMT_NOEXCEPT {
if (file_ && FMT_SYSTEM(fclose(file_)) != 0)
report_system_error(errno, "cannot close file");
}
BufferedFile::BufferedFile(cstring_view filename, cstring_view mode) {
buffered_file::buffered_file(cstring_view filename, cstring_view mode) {
FMT_RETRY_VAL(file_,
FMT_SYSTEM(fopen(filename.c_str(), mode.c_str())), FMT_NULL);
if (!file_)
FMT_THROW(system_error(errno, "cannot open file {}", filename.c_str()));
}
void BufferedFile::close() {
void buffered_file::close() {
if (!file_)
return;
int result = FMT_SYSTEM(fclose(file_));
@ -90,7 +90,7 @@ void BufferedFile::close() {
// A macro used to prevent expansion of fileno on broken versions of MinGW.
#define FMT_ARGS
int BufferedFile::fileno() const {
int buffered_file::fileno() const {
int fd = FMT_POSIX_CALL(fileno FMT_ARGS(file_));
if (fd == -1)
FMT_THROW(system_error(errno, "cannot get file descriptor"));
@ -217,13 +217,13 @@ void File::pipe(File &read_end, File &write_end) {
write_end = File(fds[1]);
}
BufferedFile File::fdopen(const char *mode) {
buffered_file File::fdopen(const char *mode) {
// Don't retry as fdopen doesn't return EINTR.
FILE *f = FMT_POSIX_CALL(fdopen(fd_, mode));
if (!f)
FMT_THROW(system_error(errno,
"cannot associate stream with file descriptor"));
BufferedFile file(f);
buffered_file file(f);
fd_ = -1;
return file;
}

View File

@ -1207,23 +1207,23 @@ TEST(FormatterTest, Examples) {
}
TEST(FormatIntTest, Data) {
fmt::FormatInt format_int(42);
fmt::format_int format_int(42);
EXPECT_EQ("42", std::string(format_int.data(), format_int.size()));
}
TEST(FormatIntTest, FormatInt) {
EXPECT_EQ("42", fmt::FormatInt(42).str());
EXPECT_EQ(2u, fmt::FormatInt(42).size());
EXPECT_EQ("-42", fmt::FormatInt(-42).str());
EXPECT_EQ(3u, fmt::FormatInt(-42).size());
EXPECT_EQ("42", fmt::FormatInt(42ul).str());
EXPECT_EQ("-42", fmt::FormatInt(-42l).str());
EXPECT_EQ("42", fmt::FormatInt(42ull).str());
EXPECT_EQ("-42", fmt::FormatInt(-42ll).str());
EXPECT_EQ("42", fmt::format_int(42).str());
EXPECT_EQ(2u, fmt::format_int(42).size());
EXPECT_EQ("-42", fmt::format_int(-42).str());
EXPECT_EQ(3u, fmt::format_int(-42).size());
EXPECT_EQ("42", fmt::format_int(42ul).str());
EXPECT_EQ("-42", fmt::format_int(-42l).str());
EXPECT_EQ("42", fmt::format_int(42ull).str());
EXPECT_EQ("-42", fmt::format_int(-42ll).str());
std::ostringstream os;
os << std::numeric_limits<int64_t>::max();
EXPECT_EQ(os.str(),
fmt::FormatInt(std::numeric_limits<int64_t>::max()).str());
fmt::format_int(std::numeric_limits<int64_t>::max()).str());
}
template <typename T>

View File

@ -306,7 +306,7 @@ TEST(UtilTest, FormatSystemError) {
#if FMT_USE_FILE_DESCRIPTORS
using fmt::BufferedFile;
using fmt::buffered_file;
using fmt::ErrorCode;
using fmt::File;
@ -319,7 +319,7 @@ TEST(OutputRedirectTest, ScopedRedirect) {
File read_end, write_end;
File::pipe(read_end, write_end);
{
BufferedFile file(write_end.fdopen("w"));
buffered_file file(write_end.fdopen("w"));
std::fprintf(file.get(), "[[[");
{
OutputRedirect redir(file.get());
@ -336,7 +336,7 @@ TEST(OutputRedirectTest, FlushErrorInCtor) {
File::pipe(read_end, write_end);
int write_fd = write_end.descriptor();
File write_copy = write_end.dup(write_fd);
BufferedFile f = write_end.fdopen("w");
buffered_file f = write_end.fdopen("w");
// Put a character in a file buffer.
EXPECT_EQ('x', fputc('x', f.get()));
FMT_POSIX(close(write_fd));
@ -348,7 +348,7 @@ TEST(OutputRedirectTest, FlushErrorInCtor) {
}
TEST(OutputRedirectTest, DupErrorInCtor) {
BufferedFile f = open_buffered_file();
buffered_file f = open_buffered_file();
int fd = (f.fileno)();
File copy = File::dup(fd);
FMT_POSIX(close(fd));
@ -361,14 +361,14 @@ TEST(OutputRedirectTest, DupErrorInCtor) {
TEST(OutputRedirectTest, RestoreAndRead) {
File read_end, write_end;
File::pipe(read_end, write_end);
BufferedFile file(write_end.fdopen("w"));
buffered_file file(write_end.fdopen("w"));
std::fprintf(file.get(), "[[[");
OutputRedirect redir(file.get());
std::fprintf(file.get(), "censored");
EXPECT_EQ("censored", sanitize(redir.restore_and_read()));
EXPECT_EQ("", sanitize(redir.restore_and_read()));
std::fprintf(file.get(), "]]]");
file = BufferedFile();
file = buffered_file();
EXPECT_READ(read_end, "[[[]]]");
}
@ -378,7 +378,7 @@ TEST(OutputRedirectTest, FlushErrorInRestoreAndRead) {
File::pipe(read_end, write_end);
int write_fd = write_end.descriptor();
File write_copy = write_end.dup(write_fd);
BufferedFile f = write_end.fdopen("w");
buffered_file f = write_end.fdopen("w");
OutputRedirect redir(f.get());
// Put a character in a file buffer.
EXPECT_EQ('x', fputc('x', f.get()));
@ -393,7 +393,7 @@ TEST(OutputRedirectTest, ErrorInDtor) {
File::pipe(read_end, write_end);
int write_fd = write_end.descriptor();
File write_copy = write_end.dup(write_fd);
BufferedFile f = write_end.fdopen("w");
buffered_file f = write_end.fdopen("w");
scoped_ptr<OutputRedirect> redir(new OutputRedirect(f.get()));
// Put a character in a file buffer.
EXPECT_EQ('x', fputc('x', f.get()));
@ -405,7 +405,7 @@ TEST(OutputRedirectTest, ErrorInDtor) {
FMT_POSIX(close(write_fd));
SUPPRESS_ASSERT(redir.reset());
}, format_system_error(EBADF, "cannot flush stream"));
write_copy.dup2(write_fd); // "undo" close or dtor of BufferedFile will fail
write_copy.dup2(write_fd); // "undo" close or dtor of buffered_file will fail
}
#endif // FMT_USE_FILE_DESCRIPTORS

View File

@ -25,7 +25,7 @@
#include "gtest-extra.h"
#include "util.h"
using fmt::BufferedFile;
using fmt::buffered_file;
using fmt::ErrorCode;
using fmt::File;
@ -194,7 +194,7 @@ int (test::fileno)(FILE *stream) {
#endif
void write_file(fmt::cstring_view filename, fmt::string_view content) {
fmt::BufferedFile f(filename, "w");
fmt::buffered_file f(filename, "w");
f.print("{}", content);
}
@ -383,8 +383,8 @@ TEST(FileTest, FdopenNoRetry) {
TEST(BufferedFileTest, OpenRetry) {
write_file("test", "there must be something here");
scoped_ptr<BufferedFile> f;
EXPECT_RETRY(f.reset(new BufferedFile("test", "r")),
scoped_ptr<buffered_file> f;
EXPECT_RETRY(f.reset(new buffered_file("test", "r")),
fopen, "cannot open file test");
#ifndef _WIN32
char c = 0;
@ -396,7 +396,7 @@ TEST(BufferedFileTest, OpenRetry) {
TEST(BufferedFileTest, CloseNoRetryInDtor) {
File read_end, write_end;
File::pipe(read_end, write_end);
scoped_ptr<BufferedFile> f(new BufferedFile(read_end.fdopen("r")));
scoped_ptr<buffered_file> f(new buffered_file(read_end.fdopen("r")));
int saved_fclose_count = 0;
EXPECT_WRITE(stderr, {
fclose_count = 1;
@ -410,7 +410,7 @@ TEST(BufferedFileTest, CloseNoRetryInDtor) {
TEST(BufferedFileTest, CloseNoRetry) {
File read_end, write_end;
File::pipe(read_end, write_end);
BufferedFile f = read_end.fdopen("r");
buffered_file f = read_end.fdopen("r");
fclose_count = 1;
EXPECT_SYSTEM_ERROR(f.close(), EINTR, "cannot close file");
EXPECT_EQ(2, fclose_count);
@ -420,7 +420,7 @@ TEST(BufferedFileTest, CloseNoRetry) {
TEST(BufferedFileTest, FilenoNoRetry) {
File read_end, write_end;
File::pipe(read_end, write_end);
BufferedFile f = read_end.fdopen("r");
buffered_file f = read_end.fdopen("r");
fileno_count = 1;
EXPECT_SYSTEM_ERROR((f.fileno)(), EINTR, "cannot get file descriptor");
EXPECT_EQ(2, fileno_count);

View File

@ -16,7 +16,7 @@
# undef fileno
#endif
using fmt::BufferedFile;
using fmt::buffered_file;
using fmt::ErrorCode;
using fmt::File;
@ -58,32 +58,32 @@ void write(File &f, fmt::string_view s) {
}
TEST(BufferedFileTest, DefaultCtor) {
BufferedFile f;
buffered_file f;
EXPECT_TRUE(f.get() == 0);
}
TEST(BufferedFileTest, MoveCtor) {
BufferedFile bf = open_buffered_file();
buffered_file bf = open_buffered_file();
FILE *fp = bf.get();
EXPECT_TRUE(fp != 0);
BufferedFile bf2(std::move(bf));
buffered_file bf2(std::move(bf));
EXPECT_EQ(fp, bf2.get());
EXPECT_TRUE(bf.get() == 0);
}
TEST(BufferedFileTest, MoveAssignment) {
BufferedFile bf = open_buffered_file();
buffered_file bf = open_buffered_file();
FILE *fp = bf.get();
EXPECT_TRUE(fp != 0);
BufferedFile bf2;
buffered_file bf2;
bf2 = std::move(bf);
EXPECT_EQ(fp, bf2.get());
EXPECT_TRUE(bf.get() == 0);
}
TEST(BufferedFileTest, MoveAssignmentClosesFile) {
BufferedFile bf = open_buffered_file();
BufferedFile bf2 = open_buffered_file();
buffered_file bf = open_buffered_file();
buffered_file bf2 = open_buffered_file();
int old_fd = bf2.fileno();
bf2 = std::move(bf);
EXPECT_TRUE(isclosed(old_fd));
@ -91,19 +91,19 @@ TEST(BufferedFileTest, MoveAssignmentClosesFile) {
TEST(BufferedFileTest, MoveFromTemporaryInCtor) {
FILE *fp = 0;
BufferedFile f(open_buffered_file(&fp));
buffered_file f(open_buffered_file(&fp));
EXPECT_EQ(fp, f.get());
}
TEST(BufferedFileTest, MoveFromTemporaryInAssignment) {
FILE *fp = 0;
BufferedFile f;
buffered_file f;
f = open_buffered_file(&fp);
EXPECT_EQ(fp, f.get());
}
TEST(BufferedFileTest, MoveFromTemporaryInAssignmentClosesFile) {
BufferedFile f = open_buffered_file();
buffered_file f = open_buffered_file();
int old_fd = f.fileno();
f = open_buffered_file();
EXPECT_TRUE(isclosed(old_fd));
@ -112,14 +112,14 @@ TEST(BufferedFileTest, MoveFromTemporaryInAssignmentClosesFile) {
TEST(BufferedFileTest, CloseFileInDtor) {
int fd = 0;
{
BufferedFile f = open_buffered_file();
buffered_file f = open_buffered_file();
fd = f.fileno();
}
EXPECT_TRUE(isclosed(fd));
}
TEST(BufferedFileTest, CloseErrorInDtor) {
scoped_ptr<BufferedFile> f(new BufferedFile(open_buffered_file()));
scoped_ptr<buffered_file> f(new buffered_file(open_buffered_file()));
EXPECT_WRITE(stderr, {
// The close function must be called inside EXPECT_WRITE, otherwise
// the system may recycle closed file descriptor when redirecting the
@ -131,7 +131,7 @@ TEST(BufferedFileTest, CloseErrorInDtor) {
}
TEST(BufferedFileTest, Close) {
BufferedFile f = open_buffered_file();
buffered_file f = open_buffered_file();
int fd = f.fileno();
f.close();
EXPECT_TRUE(f.get() == 0);
@ -139,14 +139,14 @@ TEST(BufferedFileTest, Close) {
}
TEST(BufferedFileTest, CloseError) {
BufferedFile f = open_buffered_file();
buffered_file f = open_buffered_file();
FMT_POSIX(close(f.fileno()));
EXPECT_SYSTEM_ERROR_NOASSERT(f.close(), EBADF, "cannot close file");
EXPECT_TRUE(f.get() == 0);
}
TEST(BufferedFileTest, Fileno) {
BufferedFile f;
buffered_file f;
#ifndef __COVERITY__
// fileno on a null FILE pointer either crashes or returns an error.
// Disable Coverity because this is intentional.

View File

@ -32,12 +32,12 @@ std::string get_system_error(int error_code) {
const char *const FILE_CONTENT = "Don't panic!";
fmt::BufferedFile open_buffered_file(FILE **fp) {
fmt::buffered_file open_buffered_file(FILE **fp) {
fmt::File read_end, write_end;
fmt::File::pipe(read_end, write_end);
write_end.write(FILE_CONTENT, std::strlen(FILE_CONTENT));
write_end.close();
fmt::BufferedFile f = read_end.fdopen("r");
fmt::buffered_file f = read_end.fdopen("r");
if (fp)
*fp = f.get();
return f;

View File

@ -35,7 +35,7 @@ std::string get_system_error(int error_code);
extern const char *const FILE_CONTENT;
// Opens a buffered file for reading.
fmt::BufferedFile open_buffered_file(FILE **fp = 0);
fmt::buffered_file open_buffered_file(FILE **fp = 0);
inline FILE *safe_fopen(const char *filename, const char *mode) {
#if defined(_WIN32) && !defined(__MINGW32__)