aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLucian Petrut <lpetrut@cloudbasesolutions.com>2020-05-22 07:18:50 +0000
committerVictor Zverovich <victor.zverovich@gmail.com>2020-05-26 06:39:22 -0700
commit51bf9cfacb644659e5d9c7e6fe66396726f2f4f4 (patch)
tree7a671c2d4470222869bd552b9429853d96fe094c /src
parent1a716caf5d39779f4791a40ad339c571b93fa2d0 (diff)
downloadfmtlib-51bf9cfacb644659e5d9c7e6fe66396726f2f4f4.tar.gz
Fix Mingw support
If the ``_POSIX_`` flag is set, _fdopen will not be defined by Mingw headers, which is addressed by this commit. For what is worth, as opposed to ``fdopen``, ``_pipe`` *will* actually have the ``_`` prefix when ``_POSIX_`` is set.
Diffstat (limited to 'src')
-rw-r--r--src/os.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/os.cc b/src/os.cc
index abf6a380..386119db 100644
--- a/src/os.cc
+++ b/src/os.cc
@@ -289,7 +289,11 @@ void file::pipe(file& read_end, file& write_end) {
buffered_file file::fdopen(const char* mode) {
// Don't retry as fdopen doesn't return EINTR.
+ #if defined(__MINGW32__) && defined(_POSIX_)
+ FILE* f = ::fdopen(fd_, mode);
+ #else
FILE* f = FMT_POSIX_CALL(fdopen(fd_, mode));
+ #endif
if (!f)
FMT_THROW(
system_error(errno, "cannot associate stream with file descriptor"));