c - 错误:"不允许不完整类型" ,IAR编译器

时间:2016-10-23 08:40:03

标签: c data-structures incomplete-type

请告知,错误是什么?

.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                                        
{

};

1 个答案:

答案 0 :(得分:3)

错误是由于声明'struct Raw_data_struct'时的混合造成的。您可以查看帖子typedef struct vs struct definitions [duplicate]

要声明您的结构,您必须使用:

(?:https?:\/\/)  starts with 'http' (or https) ':\\'
(?:www.)?        domain may start with 'www.'
.+               domain name (whatever you want)
\.com            ends with '.com'
\/?              may contain '\' after

而不是:

struct Raw_data_struct {
  uint8_t time;
  uint8_t type;
  uint8_t phase;
  uint8_t status;
};

如果要同时声明struct和typedef,则必须使用:

struct {
  uint8_t time;
  uint8_t type;
  uint8_t phase;
  uint8_t status;
} Raw_data_struct;