This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Something terribly wrong with gcc-3.0.4 Linux


>>>>> "Paolo" == Paolo Carlini <pcarlini@unitus.it> writes:

    Paolo> Neal D. Becker wrote:
    Paolo> std::ios::sync_with_stdio(false);
    >> 
    Paolo> before any other output operations?
    >> 
    >> No, I haven't tried that yet, but I sure don't expect that I need to
    >> in order to not have cout << "hello world" not call write() for every
    >> character.
    >> 
    Paolo> You don't expect this, on which basis? For sure, the standard offers
    Paolo> no guarantees. Quite to the contrary,
    Paolo> std::ios::sync_with_stdio(false); is the correct approach if you want
    Paolo> to trade sync with stdio for speed: on this, see, f.i., Josuttis,
    Paolo> pp. 682.


I understand that the default for cout is to sync with stdio.  I
(naively) imagined that this meant some extra calls to the C library,
not a trip through the kernel for every character.  This is really a
surprising amount of extra overhead.  Is it possible to implement
streams to avoid this?

Josuttis pg. 682 unfortunately doesn't define the term
"synchronization".  I thought that synchronization meant that 
cout << "blah" would cause a call to C-lib flush, which should result
in no call to write.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]