c – 错误:“不允许不完整的类型”,IAR编译器
请指教,出了什么问题?
在.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;