setvbuf using IOFBF max buffer size

violette vi@violette.town
Sun May 4 03:11:48 GMT 2025


Hello mailing list people!

I am trying to print a whole screen worth of text using `printf`.
I have set my terminal as full line buffer using
`setvbuf(stdout, buf, _IOFBF, sizeof(buf)` (with a buffer size of
`UINT_16_MAX`). I am using glibc 2.41 and gcc.

Apparently, it buffers and has to print a few times times before
`fflush` is even called. It also seems that it writes to screen
the same number of time as when the buffer size is set to `BUFSIZ`.

Is there a max value on buffer size that I cannot see?

I've searched the standard (IEEE Std 1003.1, 2004 Edition) and I cannot
find anything relating to it. I've also tried searching glibc code, but
cannot find much.

Does anybody have any idea where to look for, or even a better solution
that does not involve additional libraries?

Thank you,
-violette


More information about the Libc-help mailing list