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

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

Re: [avr-gcc-list] AVR Libc int32_t and uint32_t typedefs areincorrect


From: David Brown
Subject: Re: [avr-gcc-list] AVR Libc int32_t and uint32_t typedefs areincorrect
Date: Fri, 13 Jan 2012 18:48:05 +0100
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20111105 Thunderbird/8.0

On 13/01/2012 14:37, Ruud Vlaming wrote:
On Thursday 12 January 2012, Weddington, Eric wrote:
The problem that I have with -mint8 is:
- it doesn't follow the standard
- it breaks avr-libc (or rather, avr-libc isn't adapted to it)
- people use it, because the backend hasn't been taught how to do the
right thing.

The thing is, is if the AVR backend knew how to optimize away these
superfluous promotions, then I really don't think that -mint8 would ever
really be needed. Why should a user have to specify a switch to get the
compiler to do the right thing?

The problem i have with the standard C is that it lacks a
proper 8 bit arithmetic. That is why -mint8 comes in so handy,
and produces very compact code. In many cases 8 bit are more
than enough to do the job, but within the standard you are enforced
to use a char (!) for numerical operations what in it self is already a
strange situation. Of course it would be better to follow the standard
to the letter. But if the standard does not allow for a much neaded
feature AND a hack comes along which makes it possible anyway,
than you will see that the bear is loose. (BTW you see this all the time,
in any standard, until the standard evolves so i can satisfy its users
again).

Personally i do use -mint8 alot without any problems and if
an avr-libc feature is needed (which for me is not so often),
i have quick look through the code to see if anything strange
might be expected. I cannot remember that i have encountered
much.

Here is an idea to try out - instead of using "unsigned char" and "signed char" as your basis for 8-bit data, try using C++ classes around them with arithmetic operators defined. In many cases, you can get more efficient code since there are no promotions for C++ classes.

It was a while back that I tried this, and although some code was smaller and faster than using normal uint8_t, other code was much worse. But it would be fun to try again.





reply via email to

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