2016-01-09 67 views
0

我有一點問題,而編程Atmega328應爲 ':', '', ';', '}' 或 '__attribute__' 前 '=' 令牌

這段代碼給出錯誤:

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

愛特梅爾工作室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; 

整個代碼here

+1

你應該嘗試讀一些問題的答案在這裏:爲什麼我們不能初始化成員在結構內部(http://stackoverflow.com/questions/225089/why-cant-we -initialize成員-內部-A-結構) –

回答

1

無法初始化的0成員使用該語法。您可以使用:

struct 
{ 
    const uint8_t fioletowy[3]; 
    const uint8_t blekitny[3]; 
    ... 
} kolory = 
{ 
    {255,0,255}, 
    {0,255,255}, 
    ... 
}; 
相關問題