From d231a9dfd0ed1eb2c3398273066ec13e9ae1c817 Mon Sep 17 00:00:00 2001 From: Steven Peters Date: Mon, 25 Jan 2016 17:33:02 -0800 Subject: [PATCH] Fix windows compiler warning Use fopen_s instead of fopen on Windows, and check the error code. Closes #32. --- src/console.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/console.cpp b/src/console.cpp index 0d98427..2c2fd81 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -150,8 +150,13 @@ void console_bridge::OutputHandlerSTD::log(const std::string &text, LogLevel lev console_bridge::OutputHandlerFile::OutputHandlerFile(const char *filename) : OutputHandler() { +#ifdef _MSC_VER + errno_t err = fopen_s(&file_, filename, "a"); + if (err != 0 || !file_) +#else file_ = fopen(filename, "a"); if (!file_) +#endif std::cerr << "Unable to open log file: '" << filename << "'" << std::endl; }