Re: {Spam?} strange behaviour of GSPrintf

David Ayers <[email protected]>
Newsgroups gmane.comp.lib.gnustep.user
Message-ID <[email protected]>
Sebastian Reitenbach schrieb:
> Hi,
> 
> I observed that when I compile the piece of code at the end
> gmake debug=yes
> 
> then I get the following output:
> 
> $ obj/ArrayTest
> 2006-09-17 21:34:54.322 ArrayTest[31262] Msg3
> 2006-09-17 21:34:54.323 ArrayTest[31262] Msg4
> Msg2$
> 
> when I change the line 
>   GSPrintf(stdout, @"%@", [outArray objectAtIndex: 1]);
> to 
>   GSPrintf(stdout, @"%@\n", [outArray objectAtIndex: 1]);
> 
> I get the following output:
> 
> $ obj/ArrayTest
> Msg2
> 2006-09-17 21:36:38.694 ArrayTest[28187] Msg3
> 2006-09-17 21:36:38.695 ArrayTest[28187] Msg4
> $                                                
> 
> is that explainable somehow? I compiled the sources from svn with gcc 3.3.5 
> and ffcall 1.9 on an actual OpenBSD snapshot.

Hello Sebastian,

NSLog writes to the _NSLogDescriptor (which defaults to stderr) where as
your code is telling GSPrintf to write too stdout.  The order in which
you see the output in your terminal is generally indeterminate.  I
believe that writing '\n' can produce an implicit flush() in some C
implementations.  Before the program exits, all file descriptors are
flushed.

So the output looks pretty much like what I would expect.

Cheers,
David
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.