[Icc-avr] Const arrays of pointers to const arrays
Björn Lindgren
bjonaspero at hotmail.com
Wed Sep 5 00:46:19 PDT 2007
Can someone tell me how to define a constant array of pointers to other
constant arrays.
I can do this in assembler but I want the customer to take over the
maintenance and therefore
I wish to have 100% of the code in C.
Heres a condensed version:
// pointer_test.c
const signed char sinus_tab[2][3] = {
{1,2,3},{4,5,6}};
/*** Viritual definition (I want something like this)
const signed char *pointer[2] = {
sinus_tab[1],
&sinus_tab[0][0] };*/
// Working declaration (while the definition is done in assembler)
extern const unsigned int pointer[2];
// Usage:
const signed char *get_pointer( unsigned char index ) {
return (void *)pointer[ index ];
}
In assenmler (i.e. wanted result):
.area lit(rom, con, rel)
_pointer::
.word _sinus_tab+3
.word _sinus_tab
The first constant array (sinus_tab) is ok but the second either
ends up in idata (initiated SRAM) or, I get error message like:
cast from `pointer to const signed char' to `unsigned int' is illegal in
constant expressions
Thanx for help
Björn Lindgren
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
More information about the Icc-avr
mailing list