【问题标题】:Expected ':', ',', ';', '}' or '__attribute__' before '=' token [duplicate]'=' 标记之前应为 ':'、','、';'、'}' 或 '__attribute__' [重复]
【发布时间】:2016-01-09 22:11:09
【问题描述】:

我在编写 Atmega328 时遇到了一点问题

这段代码报错:

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

在 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;

全码here

【问题讨论】:

标签: c struct compiler-errors avr atmelstudio


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-18
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多