CASE SOLVED AND CLOSED cout and cerr execute out of coded sequence
-
CASE SOLVED AND CLOSED FYI As I pointed out in my recent post, which apparently did no good, this has been brought up before. I am guilty of not going back to the original post. Being repeatedly told that I am not sharing my code is getting old. So - no need to be bothered again , let's just chalk this for yet another loop-sided discussion blaming the problem on me. Cheers CASE CLOSED Re: Unexpected sequence of cout / perror in console output - C / C++ / MFC Discussion Boards[^] SOLVED It is acceptable and normal to direct standard output and standard error to the same destination, such as the text terminal. Messages appear in the same order as the program writes them, unless buffering is involved. For example, in common situations the standard error stream is unbuffered but the standard output stream is line-buffered; in this case, text written to standard error later may appear on the terminal earlier, if the standard output stream buffer is not yet full. This is NOT a dupe, just an attempt to analyse / concentrate on specific problem. The attached code execution clearly shows that the code is NOT run in sequence coded. See line numbers - they are OUT of sequence. The lines start with 40 and end with line 49 This is superficial, but annoying problem I would like to resolve. Or just identify the reason for this behaviour. BTW - inserting sleep(1) at various places "solves the problem". cerr is used to output (stderr) to console in red AND WORKS just fine. Maybe cerr and cout have conflicting "priority" or "4 core processor " in use is an issue.
cout << " START test area " << \_\_LINE\_\_ << endl; cout << " START test area " << \_\_LINE\_\_ << endl; cerr << "Function: " << \_\_FUNCTION\_\_ << " @line " << dec << \_\_LINE\_\_ << endl; //sleep(1); //int i = 0; cerr << "TRACE TEST Function: " << \_\_FUNCTION\_\_ << " @line " << dec << \_\_LINE\_\_ << endl; cout << "\\tEND test area " << \_\_LINE\_\_ << endl; cout << "\\tEND test area " << \_\_LINE\_\_ << endl;
START test area 40
START test area 41
Function: END test area 48
END test area 49
main @line 42
TRACE TEST Function: main @line 47 -
CASE SOLVED AND CLOSED FYI As I pointed out in my recent post, which apparently did no good, this has been brought up before. I am guilty of not going back to the original post. Being repeatedly told that I am not sharing my code is getting old. So - no need to be bothered again , let's just chalk this for yet another loop-sided discussion blaming the problem on me. Cheers CASE CLOSED Re: Unexpected sequence of cout / perror in console output - C / C++ / MFC Discussion Boards[^] SOLVED It is acceptable and normal to direct standard output and standard error to the same destination, such as the text terminal. Messages appear in the same order as the program writes them, unless buffering is involved. For example, in common situations the standard error stream is unbuffered but the standard output stream is line-buffered; in this case, text written to standard error later may appear on the terminal earlier, if the standard output stream buffer is not yet full. This is NOT a dupe, just an attempt to analyse / concentrate on specific problem. The attached code execution clearly shows that the code is NOT run in sequence coded. See line numbers - they are OUT of sequence. The lines start with 40 and end with line 49 This is superficial, but annoying problem I would like to resolve. Or just identify the reason for this behaviour. BTW - inserting sleep(1) at various places "solves the problem". cerr is used to output (stderr) to console in red AND WORKS just fine. Maybe cerr and cout have conflicting "priority" or "4 core processor " in use is an issue.
cout << " START test area " << \_\_LINE\_\_ << endl; cout << " START test area " << \_\_LINE\_\_ << endl; cerr << "Function: " << \_\_FUNCTION\_\_ << " @line " << dec << \_\_LINE\_\_ << endl; //sleep(1); //int i = 0; cerr << "TRACE TEST Function: " << \_\_FUNCTION\_\_ << " @line " << dec << \_\_LINE\_\_ << endl; cout << "\\tEND test area " << \_\_LINE\_\_ << endl; cout << "\\tEND test area " << \_\_LINE\_\_ << endl;
START test area 40
START test area 41
Function: END test area 48
END test area 49
main @line 42
TRACE TEST Function: main @line 47 -
CASE SOLVED AND CLOSED FYI As I pointed out in my recent post, which apparently did no good, this has been brought up before. I am guilty of not going back to the original post. Being repeatedly told that I am not sharing my code is getting old. So - no need to be bothered again , let's just chalk this for yet another loop-sided discussion blaming the problem on me. Cheers CASE CLOSED Re: Unexpected sequence of cout / perror in console output - C / C++ / MFC Discussion Boards[^] SOLVED It is acceptable and normal to direct standard output and standard error to the same destination, such as the text terminal. Messages appear in the same order as the program writes them, unless buffering is involved. For example, in common situations the standard error stream is unbuffered but the standard output stream is line-buffered; in this case, text written to standard error later may appear on the terminal earlier, if the standard output stream buffer is not yet full. This is NOT a dupe, just an attempt to analyse / concentrate on specific problem. The attached code execution clearly shows that the code is NOT run in sequence coded. See line numbers - they are OUT of sequence. The lines start with 40 and end with line 49 This is superficial, but annoying problem I would like to resolve. Or just identify the reason for this behaviour. BTW - inserting sleep(1) at various places "solves the problem". cerr is used to output (stderr) to console in red AND WORKS just fine. Maybe cerr and cout have conflicting "priority" or "4 core processor " in use is an issue.
cout << " START test area " << \_\_LINE\_\_ << endl; cout << " START test area " << \_\_LINE\_\_ << endl; cerr << "Function: " << \_\_FUNCTION\_\_ << " @line " << dec << \_\_LINE\_\_ << endl; //sleep(1); //int i = 0; cerr << "TRACE TEST Function: " << \_\_FUNCTION\_\_ << " @line " << dec << \_\_LINE\_\_ << endl; cout << "\\tEND test area " << \_\_LINE\_\_ << endl; cout << "\\tEND test area " << \_\_LINE\_\_ << endl;
START test area 40
START test area 41
Function: END test area 48
END test area 49
main @line 42
TRACE TEST Function: main @line 47