avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] Re: [avr-gcc-list] Poll: Who uses itoa() & cowith bas


From: Joerg Wunsch
Subject: Re: [avr-libc-dev] Re: [avr-gcc-list] Poll: Who uses itoa() & cowith base != {2, 8, 10, 16}?
Date: Sat, 19 Nov 2005 20:19:39 +0100
User-agent: Mutt/1.4.2.1i

As Jörgen Birkler wrote:

> Can it be automated by the compiler?
> 
> I'm thinking something like:
> 
> inline itoa(int i,char* p,int base)
> {
>  if (some_magic_gcc_macro_is_constant_parameter(base))
>  {
>    if (base==2)
>   {
>      itoa_base2(i,p);
>    }
>    else if (base == 10)
>    {
>       itoa_base10(i,p);
>   }
> }
> else {
>   itoa_full(i,p);
> }
> }

I'll keep that idea in mind.  It might really be possible to do it,
but of course, this will all fail (and then pull in the full and slow
version) if the base value is not a compile-time constant even in
situations where base is one out of {2, 8, 10, 16}, so the fast
version would be sufficient.

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]