diff --git a/include/fmt/os.h b/include/fmt/os.h index b16441cb..95fafcf1 100644 --- a/include/fmt/os.h +++ b/include/fmt/os.h @@ -132,15 +132,8 @@ class error_code { int get() const FMT_NOEXCEPT { return value_; } }; -// Define FMT_USE_WINDOWS_H to 0 to disable use of windows.h. -// All the functionality that relies on it will be disabled too. -#ifndef _WIN32 -# define FMT_USE_WINDOWS_H 0 -#elif !defined(FMT_USE_WINDOWS_H) -# define FMT_USE_WINDOWS_H 1 -#endif -#if FMT_USE_WINDOWS_H +#ifdef _WIN32 namespace internal { // A converter from UTF-16 to UTF-8. // It is only provided for Windows since other systems support UTF-8 natively. @@ -210,7 +203,7 @@ class windows_error : public system_error { // Can be used to report errors from destructors. FMT_API void report_windows_error(int error_code, string_view message) FMT_NOEXCEPT; -#endif +#endif // _WIN32 // A buffered file. class buffered_file { diff --git a/src/os.cc b/src/os.cc index acec6cfc..10a372a4 100644 --- a/src/os.cc +++ b/src/os.cc @@ -44,7 +44,7 @@ # endif // _WIN32 #endif // FMT_USE_FCNTL -#if FMT_USE_WINDOWS_H +#ifdef _WIN32 # include #endif @@ -72,7 +72,7 @@ inline std::size_t convert_rwcount(std::size_t count) { return count; } FMT_BEGIN_NAMESPACE -#if FMT_USE_WINDOWS_H +#ifdef _WIN32 internal::utf16_to_utf8::utf16_to_utf8(wstring_view s) { if (int error_code = convert(s)) { FMT_THROW(windows_error(error_code, @@ -145,7 +145,7 @@ void report_windows_error(int error_code, fmt::string_view message) FMT_NOEXCEPT { report_error(internal::format_windows_error, error_code, message); } -#endif // FMT_USE_WINDOWS_H +#endif // _WIN32 buffered_file::~buffered_file() FMT_NOEXCEPT { if (file_ && FMT_SYSTEM(fclose(file_)) != 0) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 73919da0..ad391c22 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -171,18 +171,6 @@ if (FMT_PEDANTIC) target_compile_definitions( nolocale-test PRIVATE FMT_STATIC_THOUSANDS_SEPARATOR=1) - # Test that the library compiles without windows.h. - if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - add_library(no-windows-h-test ../src/format.cc) - target_include_directories( - no-windows-h-test PRIVATE ${PROJECT_SOURCE_DIR}/include) - target_compile_definitions(no-windows-h-test PRIVATE FMT_USE_WINDOWS_H=0) - if (FMT_PEDANTIC) - target_compile_options(no-windows-h-test PRIVATE ${PEDANTIC_COMPILE_FLAGS}) - endif () - target_include_directories(no-windows-h-test SYSTEM PUBLIC gtest gmock) - endif () - add_test(compile-error-test ${CMAKE_CTEST_COMMAND} --build-and-test "${CMAKE_CURRENT_SOURCE_DIR}/compile-error-test"