c-错误:“不允许使用不完整的类型"; ,IAR编译器 [英] c - Error: "incomplete type is not allowed" , IAR compiler

查看:229
本文介绍了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"时混合导致的.您可以看一下 typedef struct vs struct definitions [duplicate] ./p>

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

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;  

Please advise, what's wrong?

in .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);

in .c

void Getst_resp(Getst_struct  Data) //Here Error: incomplete type is not allowed                                        
{

};

解决方案

The error is due to the mixture when declaring the 'struct Raw_data_struct'. You can have a look of the post typedef struct vs struct definitions [duplicate].

To declare your struct, you have to use:

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

Instead of :

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

If you want to declare both the struct and the typedef, you have to use:

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

这篇关于c-错误:“不允许使用不完整的类型"; ,IAR编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆