初始化結構時出現奇怪的編譯器錯誤。使用struct時編譯器錯誤
#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: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘.’ token
testserver.c:16:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘.’ token
testserver.c:17:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘.’ token
testserver.c:18:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘.’ token
爲什麼會出現這個錯誤?
你能粘貼整個代碼片段嗎?包括哪些函數出現在.. – yan
看看行號 - 我認爲這是他真實的代碼(我想他可能暫時忘記了這個函數,但也許不是......) – bdonlan