From 0e09ecbaa5d90746f130c12ea4329d54b8e0d9ae Mon Sep 17 00:00:00 2001 From: Charles Milette Date: Sun, 3 Nov 2019 22:41:55 -0500 Subject: [PATCH] Correctly guard SetHandleInformation API call `__cplusplus_winrt` only detected C++/CX (which can be used without compiling for UWP, SetHandleInformation would be available in those cases), and did not detect native UWP C++. This patch fixes that by using the WINAPI_FAMILY_PARTITION macro in the Windows SDK headers in the same way those headers remove SetHandleInformation in UWP builds. --- include/spdlog/details/os-inl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/spdlog/details/os-inl.h b/include/spdlog/details/os-inl.h index f03cf310..6f5ee52b 100644 --- a/include/spdlog/details/os-inl.h +++ b/include/spdlog/details/os-inl.h @@ -130,7 +130,7 @@ SPDLOG_INLINE void prevent_child_fd(FILE *f) { #ifdef _WIN32 -#if !defined(__cplusplus_winrt) +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) auto file_handle = reinterpret_cast(_get_osfhandle(::_fileno(f))); if (!::SetHandleInformation(file_handle, HANDLE_FLAG_INHERIT, 0)) SPDLOG_THROW(spdlog_ex("SetHandleInformation failed", errno));