Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c - Error: "incomplete type is not allowed" , IAR compiler

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                                        
{

};
like image 298
Yaroslav Kirillov Avatar asked Aug 31 '25 22:08

Yaroslav Kirillov


1 Answers

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;  
like image 85
J. Piquard Avatar answered Sep 04 '25 11:09

J. Piquard