Don't use POSIX API on UWP

This commit is contained in:
Victor Zverovich 2019-11-15 07:32:50 -08:00
parent c58b7d9c2f
commit 9b7fe2a4a1
3 changed files with 8 additions and 4 deletions

View File

@ -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
@ -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)

View File

@ -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)

View File

@ -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;