printf() woes

Jeff Johnston
Wed Jan 30 20:07:00 GMT 2008

Rick Mann wrote:
> Hi. I'm using newlib 1.14 on an Atmel ARM processor, and printf() is 
> behaving strangely.
> The following code
>     printf("1. Hello worldCRLF1\r\n");
>     printf("2. Hello worldCRLF\r\n");
>     printf("3. Hello worldCRLF\r\nHello worldCRLF\r\n");
>     printf("4. Hello worldLF\nHello worldLF\n");
>     printf("5. Hello worldNULL");
>     printf("6. Hello worldLF\n");
> prints:
> 3. Hello worldCRLF1
> 4. Hello worldLF
>                 Hello worldLF6. Hello worldLF
> Using snprintf() works just fine.

Did you attempt to write the result out?

> Newlib's printf() is doing something with newlines, and printf() calls 
> without newline, and not handling it the way I really want. Perhaps it's 
> a configuration things somewhere, but I don't really know where to look.
> Any suggestions?

I would suggest upgrading to newlib 1.16.0 to see if any fixes were made 
that solve your problem.  Looking through the ChangeLog, none are 
obvious, but it still helps to be current so others can better help you.

Next, I would suggest debugging inside _sfvwrite() to see what it thinks 
it is doing.  I would also suggest putting breakpoints inside the _write 
syscall to see what it is being called with each time.  This should help 
you pinpoint the problem.

-- Jeff J.

More information about the Newlib mailing list