This is the mail archive of the mailing list for the newlib 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: Buffered I/O issues (stdout, stdin)

Hi Matthew,
I'm having some trouble with a port of Newlib 1.15.0 to my operating
system in the printf function. It seems that the streams are all using
buffered I/O and if the last string printed does not have a newline it
simply is not printed at all.
FILEs are by default line buffered, meaning that nothing will be written or read until a newline symbol is encountered.
You can modify this behavior by using the setbuf() or setvbuf() methods.
I also notice strange behavior with this sort of code:

printf( "testing 123: %s\n", "hello\nworld" );

The output will be "testing 123: hello\n", which doesn't seem to be
correct. The write system call is only called for the characters
actually printed, not for the ones after, and including, the newline
(ie, "\nworld").
Did you check errno after calling printf ? You will probably get something.
This happens if you don't return the correct numbers of bytes written by your stdout driver.


-- Xavier Guérin - Doctoral student TIMA Laboratory, SLS Group 46, av. Félix Viallet, 38000 GRENOBLE, FR Mail : Phone : +33(0)4 76 57 47 59 Ad Astra Per Aspera

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