[libcxx-commits] [libcxx] [libc++] Fix checks for terminal and flushes in std::print() (PR #70321)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Mar 10 06:19:19 PDT 2026
================
@@ -236,26 +236,11 @@ __vprint_nonunicode(FILE* __stream, string_view __fmt, format_args __args, bool
// terminal when the output is redirected. Typically during testing the
// output is redirected to be able to capture it. This makes it hard to
// test this code path.
-template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
-_LIBCPP_HIDE_FROM_ABI inline void
-__vprint_unicode_posix(FILE* __stream, string_view __fmt, format_args __args, bool __write_nl, bool __is_terminal) {
- // TODO PRINT Should flush errors throw too?
- if (__is_terminal)
- std::fflush(__stream);
-
- __print::__vprint_nonunicode(__stream, __fmt, __args, __write_nl);
-}
# if _LIBCPP_HAS_WIDE_CHARACTERS
template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
_LIBCPP_HIDE_FROM_ABI inline void
-__vprint_unicode_windows(FILE* __stream, string_view __fmt, format_args __args, bool __write_nl, bool __is_terminal) {
- if (!__is_terminal)
- return __print::__vprint_nonunicode(__stream, __fmt, __args, __write_nl);
-
- // TODO PRINT Should flush errors throw too?
- std::fflush(__stream);
----------------
philnik777 wrote:
I'm still not sure I understand the point. The paper seems to say that synchronization between `stdout` and the native API should be required, but then requires outright flushing of the stream. AFAICT that means if you want to call a special unicode API, but that synchronizes with `stdout` on its own you still need to flush `stdout`. In other words, you're not allowed to keep the output of any non-unicode-api data in a buffer if you use a unicode API even though that API could write into the very same buffer.
https://github.com/llvm/llvm-project/pull/70321
More information about the libcxx-commits
mailing list