Skip to content

Commit

Permalink
Don't use POSIX API on UWP
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Nov 17, 2019
1 parent c58b7d9 commit 9b7fe2a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
9 changes: 7 additions & 2 deletions include/fmt/posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@

#include "format.h"

#if FMT_HAS_INCLUDE("fcntl.h")
// UWP doesn't provide _pipe.
#if FMT_HAS_INCLUDE("winapifamily.h")
# include <winapifamily.h>
#endif
#if FMT_HAS_INCLUDE("fcntl.h") && \
(!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
# include <fcntl.h> // for O_RDONLY
# define FMT_USE_FCNTL 1
#else
Expand Down Expand Up @@ -60,7 +65,7 @@
#ifndef _WIN32
# define FMT_RETRY_VAL(result, expression, error_result) \
do { \
(result) = (expression); \
(result) = (expression); \
} while ((result) == (error_result) && errno == EINTR)
#else
# define FMT_RETRY_VAL(result, expression, error_result) result = (expression)
Expand Down
1 change: 0 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ if (NOT MSVC_BUILD_STATIC)
posix-mock-test.cc ../src/format.cc ${TEST_MAIN_SRC})
target_include_directories(
posix-mock-test PRIVATE ${PROJECT_SOURCE_DIR}/include)
target_compile_definitions(posix-mock-test PRIVATE FMT_USE_FILE_DESCRIPTORS=1)
target_link_libraries(posix-mock-test gmock)
target_include_directories(posix-mock-test SYSTEM PUBLIC gtest gmock)
if (FMT_PEDANTIC)
Expand Down
2 changes: 1 addition & 1 deletion test/gtest-extra.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ std::string read(file& f, std::size_t count) {
return buffer;
}

#endif // FMT_USE_FILE_DESCRIPTORS
#endif // FMT_USE_FCNTL

std::string format_system_error(int error_code, fmt::string_view message) {
fmt::memory_buffer out;
Expand Down

0 comments on commit 9b7fe2a

Please sign in to comment.