mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-25 15:21:54 +00:00
Changes for MinGW compiler
This commit is contained in:
parent
e2cbee77b8
commit
6aace693db
@ -42,6 +42,9 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# define WIN32_LEAN_AND_MEAN
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# ifdef __MINGW32__
|
||||||
|
# include <cstring>
|
||||||
|
# endif
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# undef ERROR
|
# undef ERROR
|
||||||
#endif
|
#endif
|
||||||
@ -228,7 +231,11 @@ int fmt::internal::StrError(
|
|||||||
result = ERANGE;
|
result = ERANGE;
|
||||||
buffer = message;
|
buffer = message;
|
||||||
#elif _WIN32
|
#elif _WIN32
|
||||||
|
# ifdef __MINGW32__
|
||||||
|
strerror(result);
|
||||||
|
# else
|
||||||
result = strerror_s(buffer, buffer_size, error_code);
|
result = strerror_s(buffer, buffer_size, error_code);
|
||||||
|
# endif
|
||||||
// If the buffer is full then the message is probably truncated.
|
// If the buffer is full then the message is probably truncated.
|
||||||
if (result == 0 && std::strlen(buffer) == buffer_size - 1)
|
if (result == 0 && std::strlen(buffer) == buffer_size - 1)
|
||||||
result = ERANGE;
|
result = ERANGE;
|
||||||
|
4
posix.cc
4
posix.cc
@ -41,6 +41,10 @@
|
|||||||
# define S_IRUSR _S_IREAD
|
# define S_IRUSR _S_IREAD
|
||||||
# define S_IWUSR _S_IWRITE
|
# define S_IWUSR _S_IWRITE
|
||||||
|
|
||||||
|
# ifdef __MINGW32__
|
||||||
|
# define _SH_DENYNO 0x40
|
||||||
|
# endif
|
||||||
|
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||||
// Fix MSVC warning about "unsafe" fopen.
|
// Fix MSVC warning about "unsafe" fopen.
|
||||||
FILE *FOpen(const char *filename, const char *mode) {
|
FILE *FOpen(const char *filename, const char *mode) {
|
||||||
FILE *f = 0;
|
FILE *f = 0;
|
||||||
|
@ -32,13 +32,13 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <gtest/gtest-spi.h>
|
#include <gtest/gtest-spi.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||||
# include <crtdbg.h> // for _CrtSetReportMode
|
# include <crtdbg.h> // for _CrtSetReportMode
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||||
|
|
||||||
// Suppresses Windows assertions on invalid file descriptors, making
|
// Suppresses Windows assertions on invalid file descriptors, making
|
||||||
// POSIX functions return proper error codes instead of crashing on Windows.
|
// POSIX functions return proper error codes instead of crashing on Windows.
|
||||||
|
@ -43,7 +43,7 @@ using fmt::StringRef;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
std::string GetSystemErrorMessage(int error_code) {
|
std::string GetSystemErrorMessage(int error_code) {
|
||||||
#ifndef _WIN32
|
#if defined(__MINGW32__) || !defined(_WIN32)
|
||||||
return strerror(error_code);
|
return strerror(error_code);
|
||||||
#else
|
#else
|
||||||
enum { BUFFER_SIZE = 200 };
|
enum { BUFFER_SIZE = 200 };
|
||||||
|
Loading…
Reference in New Issue
Block a user