I don't think the compiler can tell what the address of "x" would be at
compile time. Common practice is to initialize such a table at run time.
I can imagine (just a thought), an assembler .org directive to reserve a
pgm memory for your table at fixed address which would be a constant
expression then, but it's not worth doing in my opinion.

Regards, Marek

On Sat, 2011-03-19 at 00:20 +0100, Volkmar Dierkes wrote:
> Hello,
> 
> I want to create a table like this:
> 
> unsigned char lcd_display_function[] PROGMEM = {
>          LOK_FCT0_POSX, LOK_FCT0_POSY, LOK_FCT0_ENDX, LOK_FCT0_POSY, 
> SOFTKEY_BORDER0_COLOR,
>         CLCD_FIFO_CMD_SUBEND};
> 
> Each value is a constant in a range of 0<=x<=255 defined with #define.
> 
> This works fine so far, but I am in the need to add also an address of
> another table in PROGMEM, like this:
> 
> unsigned char foo[] PROGMEM = {0, 1, 2};
> 
> I tried several ways to add this to the list above, like this:
> 
> #define lo8(x) (((int)(x)&0xff))
> #define hi8(x) (((int)(x)>>8))
> 
> unsigned char lcd_display_function[] PROGMEM = {
>         CLCD_FIFO_CMD_FILLRECT, LOK_FCT0_POSX, LOK_FCT0_POSY, LOK_FCT0_ENDX, 
> LOK_FCT0_POSY, SOFTKEY_BORDER0_COLOR,
>         lo8(foo), hi8(foo),
>         CLCD_FIFO_CMD_SUBEND};
> 
> but it results always in an error:
> error: initializer element is not constant
> 
> Do you have any idea how this could be solved?
> 
> Thanks
> Volkmar
> 
> 
> 
> _______________________________________________
> AVR-libc-dev mailing list
> AVR-libc-dev@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/avr-libc-dev



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Reply via email to