|
From: | Eric Weddington |
Subject: | [avr-libc-dev] Re: [avrdude-dev] Problems with -O2 and gcc-4.0 on Darwin |
Date: | Tue, 04 Apr 2006 13:57:15 -0600 |
User-agent: | Mozilla Thunderbird 1.0.2 (Windows/20050317) |
Joerg Wunsch wrote:
So the code that's generated is equivalent to what you get with _BV() and with bitfields, only it's more type-safe.Well, using bit numbers is not our invention: it's Atmel's idea. We are basically bound to it since it's the de-facto standard for the AVR. Personally, I find it stupid as well, as any seasoned C programmer would have standardized the bitmasks instead of their numbers, but obviously, these header files are intented not only for C but also for assembly programmers, and these do need the bit numbers occasionally (like in SBI or CBI instructions).
IYHO. :-) Personally I don't find thim as stupid; there are many different ways to achieve the same thing. As long as the bit numbers are constants then the compiler will do the heavy lifting of creating the bit mask, so no penalty is involved in using them. Sometimes I find it easier to think about the bit number needed than thinking about the bit mask.
Bitfields have their place too, but I find it overkill when using them just to work with one bit. Plus, using the bitwise operators allows greater flexibility.
Really, this conversation should be taken over to the avr-libc-dev mailing list, ...Agreed.
CCed. -- Eric Weddington
[Prev in Thread] | Current Thread | [Next in Thread] |