std::cerr, std::wcerr
Aus cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody>| definiert in Header <iostream>
|
||
extern std::ostream cerr; |
(1) | |
extern std::wostream wcerr; |
(2) | |
Die globale Objekte std::cerr und std::wcerr Steuerausgang zu einem Strom-Puffer der Umsetzung Typs (abgeleitet von std::streambuf und std::wstreambuf bezeichnet), mit dem Standard-C Fehlerausgabe-Stream zugeordnet stderr .
Original:
The global objects std::cerr and std::wcerr control output to a stream buffer of implementation-defined type (derived from std::streambuf and std::wstreambuf, respectively), associated with the standard C error output stream stderr.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Diese Objekte sind garantiert gebaut, bevor die erste Konstruktor einer statischen Objekt aufgerufen werden, und sie werden garantiert, um die letzten Destruktor eines statischen Objekts überleben, so dass es immer möglich ist, um std::cerr im User-Code zu schreiben .
Original:
These objects are guaranteed to be constructed before the first constructor of a static object is called and they are guaranteed to outlive the last destructor of a static object, so that it is always possible to write to std::cerr in user code.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Sofern
sync_with_stdio(false) ausgestellt wurde, ist es sicher den gleichzeitigen Zugriff auf diese Objekte aus mehreren Threads sowohl für formatierte und unformatierte Ausgabe .Original:
Unless
sync_with_stdio(false) has been issued, it is safe to concurrently access these objects from multiple threads for both formatted and unformatted output.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Einmal initialisiert
std::cerr.flags() & unitbuf != 0 (gleich für wcerr) Bedeutung, dass alle Ausgaben, die an diese Stream-Objekte sofort an den OS gespült (via std::basic_ostream::sentry Destruktor) .Original:
Once initialized,
std::cerr.flags() & unitbuf != 0 (same for wcerr) meaning that any output sent to these stream objects is immediately flushed to the OS (via std::basic_ostream::sentry's destructor).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Darüber hinaus bedeutet
std::cerr.tie() kehrt &std::cout (gleich für wcerr und wcout), dass jede Ausgabe-Operation am std::cerr führt zunächst std::cout.flush() (via std::basic_ostream::sentry Konstruktor) (seit C++11)Original:
In addition,
std::cerr.tie() returns &std::cout (same for wcerr and wcout), meaning that any output operation on std::cerr first executes std::cout.flush() (via std::basic_ostream::sentry's constructor) (seit C++11)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Beispiel
Ausgabe auf stderr über cerr spült die anstehende Ausgabe auf cout, während an stderr über verstopfen nicht
Original:
output to stderr via cerr flushes out the pending output on cout, while output to stderr via clog does not
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
#include <thread>
#include <iostream>
#include <chrono>
void f()
{
std::cout << "Output from thread...";
std::this_thread::sleep_for(std::chrono::seconds(2));
std::cout << "...thread calls flush()" << std::endl;
}
int main()
{
std::thread t1(f);
std::this_thread::sleep_for(std::chrono::seconds(1));
std::clog << "This output from main is not tie()'d to cout\n";
std::cerr << "This output is tie()'d to cout\n";
t1.join();
}
Output:
This output from main is not tie()'d to cout
Output from thread...This output is tie()'d to cout
...thread calls flush()
Siehe auch
}} initialisiert Standard-Stream-Objekten Original: initializes standard stream objects The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (öffentlichen Member der Klasse of std::ios_base)
| |
schreibt der Standard-C-Fehler Stream stderr
(globales Objekt) Original: writes to the standard C error stream stderr (globales Objekt) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| schreibt in den Standard-C Ausgabe-Stream stdout (globales Objekt) | |