[英]c - Error: “incomplete type is not allowed” , IAR compiler
請指教,出了什么問題?
在.h
struct {
uint8_t time;
uint8_t type;
uint8_t phase;
uint8_t status;
} Raw_data_struct;
typedef struct Raw_data_struct Getst_struct;
void Getst_resp(Getst_struct Data);
在.c
void Getst_resp(Getst_struct Data) //Here Error: incomplete type is not allowed
{
};
該錯誤是由於聲明'struct Raw_data_struct'時的混合造成的。 您可以查看post typedef struct vs struct definitions [duplicate] 。
要聲明您的結構,您必須使用:
struct Raw_data_struct {
uint8_t time;
uint8_t type;
uint8_t phase;
uint8_t status;
};
代替 :
struct {
uint8_t time;
uint8_t type;
uint8_t phase;
uint8_t status;
} Raw_data_struct;
如果要聲明struct和typedef,則必須使用:
typedef struct Raw_data_struct {
uint8_t time;
uint8_t type;
uint8_t phase;
uint8_t status;
} Getst_struct;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.