-is-this-fft-'s blog

By -is-this-fft-, history, 4 months ago, In English

Consider this code:

#include <iostream>

using namespace std;

int main () {
  ios::sync_with_stdio(false);
  ios::sync_with_stdio(true);
}

In GCC, are the C++ streams like std::cout etc then synchronized with the corresponding C methods like printf?

Answer
  • Vote: I like it
  • +203
  • Vote: I do not like it

»
4 months ago, hide # |
 
Vote: I like it +14 Vote: I do not like it

Is this behavior the same across all compiler?
or just unique to GCC?
is it specified on the C++ standard?

Why am I not checking it myself instead of asking questions? Cause I don't know where to check.

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

So it feels like more of a "config" than "function"

»
4 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

I wonder why the C++ committee didn't do something like ios::desync_from_stdio() (without arguments), because the bool argument is really not needed.

  • »
    »
    4 months ago, hide # ^ |
     
    Vote: I like it +8 Vote: I do not like it

    Because it doesn't really matter. You either allow resync to be implemented as part of existing interface but don't force it, or you allow resync to be implemented as an extra function within a namespace (a standard library implementation is allowed to add stuff, just users aren't) but don't force it. As software design decisions go, this one isn't worth focusing on.