[libcxx-commits] [libcxx] 25a2d51 - [libc++] Guard the whole print.cpp file with _LIBCPP_WIN32API (#71122)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Nov 5 15:24:37 PST 2023


Author: Louis Dionne
Date: 2023-11-05T16:24:34-07:00
New Revision: 25a2d51842dc03a2b4cb9039aed5457495a2d29a

URL: https://github.com/llvm/llvm-project/commit/25a2d51842dc03a2b4cb9039aed5457495a2d29a
DIFF: https://github.com/llvm/llvm-project/commit/25a2d51842dc03a2b4cb9039aed5457495a2d29a.diff

LOG: [libc++] Guard the whole print.cpp file with _LIBCPP_WIN32API (#71122)

The print.cpp source file is only used when building on Windows. Avoid
including anything else but <__config> in the file in the case where
there's nothing to compile here at all. As a drive-by change, use
_LIBCPP_WIN32API consistently instead of _WIN32.

Added: 
    

Modified: 
    libcxx/src/print.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/src/print.cpp b/libcxx/src/print.cpp
index a581dd37fe788ab..3692187a5954a32 100644
--- a/libcxx/src/print.cpp
+++ b/libcxx/src/print.cpp
@@ -7,10 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include <__config>
-#include <cstdlib>
-#include <print>
 
 #if defined(_LIBCPP_WIN32API)
+
+#  include <cstdlib>
+#  include <print>
+
 #  define WIN32_LEAN_AND_MEAN
 #  define NOMINMAX
 #  include <io.h>
@@ -19,11 +21,9 @@
 #  include <__system_error/system_error.h>
 
 #  include "filesystem/error.h"
-#endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#ifdef _WIN32
 _LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream) {
   // Note the Standard does this in one call, but it's unclear whether
   // an invalid handle is allowed when calling GetConsoleMode.
@@ -52,6 +52,6 @@ __write_to_windows_console([[maybe_unused]] FILE* __stream, [[maybe_unused]] wst
 }
 #  endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
 
-#endif // _WIN32
-
 _LIBCPP_END_NAMESPACE_STD
+
+#endif // !_LIBCPP_WIN32API


        


More information about the libcxx-commits mailing list