You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Jernej Turnsek <je...@gmail.com> on 2021/05/14 10:02:42 UTC

fwrite line buffering

Hi all,

while working with stdout fwrite function, I have noticed that line
buffering is not working. Is this by design or it is a bug?

Regards,
Jernej

Re: fwrite line buffering

Posted by Jernej Turnsek <je...@gmail.com>.
Hi Alan,

"\n" does not explicitly force the flush. I have configured the line
buffering which is actually working on printf and fputs, but not on fwrite.
I am using some application code that is running ok on Linux, but on Nuttx
it is not flushing properly. It flush only when the buffer is filled. I
hope I make myself clear now.

Jernej

On Fri, May 14, 2021 at 12:22 PM Alan Carvalho de Assis <ac...@gmail.com>
wrote:

> Hi Jernej,
>
> Please define "not working"! :-)
>
> Are you flushing it? Also "\n" at end of line forces it to be flushed.
>
> BR,
>
> Alan
>
> On Friday, May 14, 2021, Jernej Turnsek <je...@gmail.com> wrote:
>
> > Hi all,
> >
> > while working with stdout fwrite function, I have noticed that line
> > buffering is not working. Is this by design or it is a bug?
> >
> > Regards,
> > Jernej
> >
>

Re: fwrite line buffering

Posted by Johnny Billquist <bq...@softjar.se>.
I think his point was that it was implicitly flushed at every write, and 
not being buffered, but I might have misunderstood.

Anyway, I wouldn't expect fwrite to buffer on a per-line basis. fwrite 
is basically there for doing binary I/O. If you want something buffered, 
line oriented and user friendly, I would suggest printf.

   Johnny

On 2021-05-14 12:22, Alan Carvalho de Assis wrote:
> Hi Jernej,
> 
> Please define "not working"! :-)
> 
> Are you flushing it? Also "\n" at end of line forces it to be flushed.
> 
> BR,
> 
> Alan
> 
> On Friday, May 14, 2021, Jernej Turnsek <je...@gmail.com> wrote:
> 
>> Hi all,
>>
>> while working with stdout fwrite function, I have noticed that line
>> buffering is not working. Is this by design or it is a bug?
>>
>> Regards,
>> Jernej
>>
> 

-- 
Johnny Billquist                  || "I'm on a bus
                                   ||  on a psychedelic trip
email: bqt@softjar.se             ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol

Re: fwrite line buffering

Posted by Alan Carvalho de Assis <ac...@gmail.com>.
Hi Jernej,

Please define "not working"! :-)

Are you flushing it? Also "\n" at end of line forces it to be flushed.

BR,

Alan

On Friday, May 14, 2021, Jernej Turnsek <je...@gmail.com> wrote:

> Hi all,
>
> while working with stdout fwrite function, I have noticed that line
> buffering is not working. Is this by design or it is a bug?
>
> Regards,
> Jernej
>