Re: Fwd: [arm-gnu] printf problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fwd: [arm-gnu] printf problem



Hi,

From the below mail,

If I try with that stub, then printf() will also works?
In my project I need, both printf() and sprintf() both to work.
For printf() to work, i need to modify the __write() to output the string to
serial port. In that case how would I differentiate the call for __write()
is either from printf() or from sprintf()?

Regards,
Ravi

On Fri, Mar 14, 2008 at 8:09 PM, Carlos O'Donell <carlos@xxxxxxxxxxxxxxxx>
wrote:

> ravi wrote:
> > __write()
> > {
> >   return 0;
> > }
> >
> > When I ran my program, it is hung inside the sprintf().
>
> The documentation for __write says it returns the number of bytes
> processed. Your stub for __write returns "0", which means "Zero bytes
> were processed." This causes sprintf to loop forever trying to process
> the bytes.
>
> Try this stub instead:
>
> __write (int fd, const void *buf, int count)
> {
>   /* Tell the C library we processed *all* the bytes.  */
>   return count;
> }
>
> Cheers,
> Carlos.
> --
> Carlos O'Donell
> CodeSourcery
> carlos@xxxxxxxxxxxxxxxx
> (650) 331-3385 x716
>



-- 
regards
ravi