This is the mail archive of the newlib@sourceware.org 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: printf and line buffering


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.
#include <stdio.h>

int main()
{
   putchar ('s');
   putchar ('o');
   putchar ('m');
   putchar ('e');
   putchar (' ');
   putchar ('l');
   putchar ('i');
   putchar ('n');
   putchar ('e');
   return 0;
}
  

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