On 03/31/14 07:44, Kun Yang wrote:
> Dear Sirs,
> I am using the EDK II 2014 to develop UEFI shell application, and
> I found when
> I use printf(), there are something wrong, but there is no error when I
> use "EDK II Standard Libraries Beta Release 4:03 PM 8/2/2011".
>
> For example :
>
> for(i=0; i<10; i++)
> {
> printf("i = %d ",i);
> sleep(1);
> }
>
> When I use EADK version 1.02 I will get the"i = 0 i =1 i = 2 i = 3
> ........."
> show together a few minute after I run the application.
> But if I use "EADK Beta Release 4:03 PM 8/2/2011", the result is
> what i want, the "i = 0" "i = 1" "i = 2" "i = 3 ........."
> will show one after one.
>
> Can Anyone help me ?
Use setvbuf() or fflush().
At program startup, three text streams are predefined and need not
be opened explicitly — standard input (for reading conventional
input), standard output (for writing conventional output), and
standard error (for writing diagnostic output). As initially
opened, the standard error stream is not fully buffered; the
standard input and standard output streams are fully buffered if
and only if the stream can be determined not to refer to an
interactive device.
The default buffering of stdout may have changed between the two
releases, from unbuffered to line buffered. Your stdout is likely
connected to a terminal, and accordingly, none of the versions select
full buffering (hence they both conform to the standard). However the
earlier version may default to unbuffered (which is OK) and the later
version may select line buffered (which is also OK).
So, you can:
- include a newline character in each string that you print, or
- select unbuffered mode with setvbuf(), or
- flush stdout with fflush() after each printf().
http://pubs.opengroup.org/onlinepubs/9699919799/functions/setvbuf.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_05
(These references don't point to the ISO C standard that the edk2 StdLib
targets, but they are relevant enough here.)
Laszlo
------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel