Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boost::nowide::cerr is buffered #186

Closed
Flamefire opened this issue Oct 16, 2024 · 1 comment · Fixed by #187
Closed

boost::nowide::cerr is buffered #186

Flamefire opened this issue Oct 16, 2024 · 1 comment · Fixed by #187

Comments

@Flamefire
Copy link
Collaborator

When using std::cerr << "Something\n" it behaves the same as std::cerr << "Something" << std::endl, i.e. any output is directly flushed/printed to the console.

However there is some buffering happening such that if the application crashes or otherwise terminates it is not ensured that the output is/was actually visible.

Investigate that e.g. the following holds:

Once initialized, (std::cerr.flags() & unitbuf) != 0 (same for std::wcerr) meaning that any output sent to these stream objects is immediately flushed to the OS (via [std::basic_ostream::sentry](https://en.cppreference.com/w/cpp/io/basic_ostream/sentry)'s destructor).

In addition, std::cerr.tie() returns &[std::cout](http://en.cppreference.com/w/cpp/io/cout) (same for std::wcerr and [std::wcout](https://en.cppreference.com/w/cpp/io/cout)), meaning that any output operation on std::cerr first executes [std::cout](http://en.cppreference.com/w/cpp/io/cout).flush() (via [std::basic_ostream::sentry](https://en.cppreference.com/w/cpp/io/basic_ostream/sentry)'s constructor).
@Flamefire
Copy link
Collaborator Author

This has been fixed for Boost 1.77 / Nowide 11.2 by 4ac0ca5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant