0

我在编程 Atmega328 时有一点问题

这段代码给出了错误:

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;

完整代码在这里

4

1 回答 1

1

您不能struct使用该语法初始化 a 的成员。您可以使用:

struct
{
   const uint8_t fioletowy[3];
   const uint8_t blekitny[3];
   ...
} kolory = 
{
   {255,0,255},
   {0,255,255},
   ...
};
于 2016-01-09T22:19:54.073 回答