I've discovered an issue using fprintf with ordinary strings. I am using avr-libc 1.7.0 with gcc 4.3.4.
I have stderr setup as follows:
FILE lcd_str = FDEV_SETUP_STREAM(LcdPutchar, NULL, _FDEV_SETUP_WRITE); stderr = lcd_str;
My LcdPutchar function simply sends a character to display at the LCD. There are no issues here, it generally runs fine. By generally I mean all the time.
The issue is the following. In my application I try to use fprintf to display a string in two different ways:
fprintf(stderr, "some string\n");
static char* str = "some string"; fprintf(stderr, "*\n" , str);
(above by '*' I mean 'percent_sign followed by s', which I don't know why is not allowed by this website ... I keep getting bad request if I put that)
The first way only calls the LcdPutchar function once, thus displaying just "s" on the LCD.
The second way (b) displays the string correctly.
Looking at the avr-libc documentation we can see that fprintf could be used in ordinary strings (which I understand is case a). This is taken from vfprintf doc (which is referred by fprintf):
"vfprintf is the central facility of the printf family of functions. It outputs values to stream under control of a format string passed in fmt. ...
The format string is composed of zero or more directives: ordinary characters (not %), which are copied unchanged to the output stream; ..."
What do you think?