Re: C both slow and memory-hungry for embedded systems?
Martin Wells wrote:
> Spiros:
>
>>> Standarising C in such a way that int is at least 16-Bit, has this
>>> made C both slow and memory-hungry for embedded systems programming?
>> What's stopping you from using (unsigned) char on such systems ?
>
>
> I write fully-portably in C89, paying no attention to the particulars
> of the platform. If I was to start using char instead of int, I'd
> introduce inefficiency on systems whose optimal int type is >= 16
> bits.
>
> I think a fair few embedded programmers are starting to use things
> like int_fastest_at_least_8 which are defined in C99.
Using int_fast8_t isn't sufficient; you also have to put the compiler
into a mode which is nonconforming either because it disables automatic
conversion to 'int' in the many contexts where that conversion is
required, or because 'int' is an 8 bit type.
The other problem, of course, is the number of C standard library
routines which take 'int' arguments and return 'int' values. However,
there's an easy workaround for that: create alternative functions that
take 8-bit arguments, where appropriate.
|