0

I have little problem while programming Atmega328

This piece of code gives error:

expected ':', ',', ';', '}' or '__attribute__' before '=' token

in Atmel Studio 7

struct
{
    const uint8_t fioletowy[3] = {255,0,255};
    const uint8_t blekitny[3] = {0,255,255};
    const uint8_t czerwony[3] = {255,0,0};
    const uint8_t zielony[3] = {0,255,0};
    const uint8_t niebieski[3] = {0,0,255};
    const uint8_t pomaranczowy[3] = {255,128,0};
    const uint8_t zolty[3] = {255,255,0};
    const uint8_t bialy[3] = {255,255,255};
    const uint8_t rozowy[3] = {255,100,255};
    const uint8_t cyjanowy[3] = {0,255,225};
} kolory;

Whole code here

KK2345
  • 11
  • 3
  • 1
    You should try reading some of the answers here: [Why can't we initialize members inside a structure](http://stackoverflow.com/questions/225089/why-cant-we-initialize-members-inside-a-structure) – Alexie Dariciuc Jan 09 '16 at 22:24

1 Answers1

1

You cannot initialize members of a struct using that syntax. You can use:

struct
{
   const uint8_t fioletowy[3];
   const uint8_t blekitny[3];
   ...
} kolory = 
{
   {255,0,255},
   {0,255,255},
   ...
};
R Sahu
  • 204,454
  • 14
  • 159
  • 270