This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

cast to structure not working

Hi, I have this code working OK in IAR 5 kickstart and GNU toolchain:

typedef struct { uint8_t r; uint8_t g; uint8_t b;
} color;

void LCD_fill(uint16_t x, uint16_t y, color fcolor)
{ [...]

LCD_fill(640,480,(color){0xff,0,0});

However, MDK414 gives the following errors:
error: #119: cast to type "color" is not allowed
error: #29: expected an expression

were the last one stays when I don't cast.

I see two issues here:
1- the impossibility to cast to the 'color' type, can be removed by adding an indirection level (but I don't want to do that for performance reasons)
2- the impossibility to use a constant structure as the parameter (I also tried defining and casting as 'const' with no success).

However, everything works OK if I define

color RED={0xff,0,0}; // or const color, btw...

and do:

LCD_fill(640,480,RED);

This looks like RealView is playing nasty on me. Any clues ?

0