Am 30.07.2010 00:09, schrieb Balog Pal:
The part I don't get is why providing initializer for all struct members
(either literally, or better yet using a macro) is so painful.
Image you have 150 ISRs. You occupy only 3 of them, #17, #99 and #130.
This means you have to write
0, (16 times)
FirstISR,
0, (81 times)
SecondISR,
0, (30 times)
ThirdISR,
0, (20 times)
Calculating these numbers by oneself is incredibly error-prone. Even
worse: If you're off-by-one (as I actually was when I first wrote these
lines) you will not get any error, but it will rain crap during runtime.
It is much less error prone to write:
..USART_RXC = FirstISR,
..Ethernet_RXC = SecondISR,
..ExternalIRQ = ThirdISR
and not have to worry about the actual positions.
Furthermore, say you insert one beween #2 and #3 (say at 104). Then you
have to split the "0, (30 times)" up (into 4 + 25) which is even more
error-prone.
Such
tables are routinely created using macros. (For those unfamiliar
with embedded, you start work by including a few hundred kByte header
with half content being #define... so using a few more hardly hurts ;-)
If you knew a way to do this with macros, I'd be fine with it. However
nobody here has come up with a solution to make this problem work with
C++ (either using macros or not). I start to believe there may be no way
to solve that using C++ (which is IMHO, a pity, considering that C can
do it with ease).
Regards,
Johannes
--
Zumindest nicht öffentlich!
Ah, der neueste und bis heute genialste Streich unsere großen
Kosmologen: Die Geheim-Vorhersage.
- Karl Kaos über Rüdiger Thomas in dsa <
[email protected]>