使用结构时编译器错误

Mik*_*ike 0 c compiler-construction compiler-errors

我在初始化结构时遇到奇怪的编译器错误.

#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;
Run Code Online (Sandbox Code Playgroud)

根据一些不同的教程,这看起来很好,但在两台不同的机器上,我在编译时遇到以下错误:

testserver.c:15:9:错误:在'.'之前预期'=',',',';','asm'或' attribute '.token
testserver.c:16:9:error:在'.'之前预期'=',',',';','asm'或' attribute '.token
testserver.c:17:9:error:在'.'之前预期'=',',',';','asm'或' attribute '.token
testserver.c:18:9:error:在'.'之前预期'=',',',';','asm'或' attribute '.代币

为什么我收到此错误?

bdo*_*lan 9

sendData.az = 25;
Run Code Online (Sandbox Code Playgroud)

像这样的语句必须在函数内部.如果要初始化结构,则有不同的语法:

struct RadarData sendData = { 25, 10, 1, 100 };
Run Code Online (Sandbox Code Playgroud)