printf and line buffering

Jeff Johnston jjohnstn@redhat.com
Thu Aug 3 20:44:00 GMT 2006


Andrew Pamment wrote:
> On Wed, 02 Aug 2006 03:38:35 +0930, Jeff Johnston <jjohnstn@redhat.com>  
> wrote:
> 
>> The following simple test case debugged under both x86-linux and 
>> mn10300  newlib has already issued the line "some line" by the time we 
>> get to  line 7: return 0.  What happens on your system?
> 
> 
> Your program works perfectly on my OS, infact I can't make it not work. :-/
> 
> At least now I know I was doing the right things, the problem is 
> probably  in my OS somewhere.
> 
> Having said that, does putchar not use buffering? I seem to be able 
> print  characters immediatly without touching setvbuf at all, is that 
> normal?
> 

Yes, putchar uses buffering just like printf does.  Try the attached 
test case under your debugger and break at the return statement.  You 
shouldn't see any output at that point.  If you add the setvbuf at the 
top, then you should.

-- Jeff J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test3.c
Type: text/x-csrc
Size: 213 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20060803/1863fe8f/attachment.bin>


More information about the Newlib mailing list