[libcxx-commits] [libcxx] [libc++] Guard the whole print.cpp file with _LIBCPP_WIN32API (PR #71122)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Nov 2 15:18:25 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Louis Dionne (ldionne)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/71122.diff
1 Files Affected:
- (modified) libcxx/src/print.cpp (+6-6)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/71122
More information about the libcxx-commits
mailing list