_IONBF drops all newlines

Nick THOMPSON nickthompson@agere.com
Mon Jun 7 15:02:00 GMT 2004

Hi all,

newlib-1.12.0, gcc 3.4 for arm-elf, custom OS.

I'm new to newlib and am trying to embed it on an ARM946. I have my code
booting nicely now with stdin/out as default settings (line buffered??).
However, my code is interactive (i.e. command line editing) and I need
stdio to be unbuffered so I can use getchar for real time char input and
putchar/printf output to control a VT100 cursor. So I added...

    setvbuf(stdin, NULL, _IONBF, 0);
    setvbuf(stdout, NULL, _IONBF, 0);

...early in my code (no output so far), but this seem to make puts not
output a \n and printf also seems to ignore any \n in the format string.
putchar('\n') works fine and my serial driver does the conversion to
CR/LR for the terminal.

I don't use crt0 and have a custom boot sequence, that sets .data and
.bss correctly. It doesn't call any kind of newlib init routines, as
there don't seem to be any (stdio initialised on the fly for example).
Have I missed something obvious?

Thanks in advance,

More information about the Newlib mailing list