【发布时间】:2025-12-21 03:30:15
【问题描述】:
我在初始化一个结构时遇到了一个奇怪的编译器错误。
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
struct RadarData
{
unsigned int messageID : 32;
unsigned int time : 32;
float az;
float el;
};
struct RadarData sendData;
sendData.az = 25;
sendData.el = 10;
sendData.messageID = 1;
sendData.time = 100;
根据几个不同的教程,这对我来说看起来不错,但是在两台不同的机器上,编译时出现以下错误:
testserver.c:15:9: 错误:在“.”令牌之前需要“=”、“,”、“;”、“asm”或“attribute”
testserver.c:16:9:错误:在“.”标记之前需要“=”、“,”、“;”、“asm”或“attribute”
testserver.c:17:9: 错误:在“.”标记之前需要“=”、“,”、“;”、“asm”或“attribute”
testserver.c:18:9:错误:在“.”标记之前应为“=”、“,”、“;”、“asm”或“attribute”
为什么会出现这个错误?
【问题讨论】:
-
你能粘贴整个代码sn-p吗?包括这出现在哪个函数中..
-
看看行号——我认为这是他真正的代码(我想他可能也暂时忘记了这个功能,但是,也许不是...... )
标签: c compiler-construction compiler-errors