4

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                                        
{

};
Saurav Sahu
  • 13,038
  • 6
  • 64
  • 79

1 Answers1

6

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;  
Community
  • 1
  • 1
J. Piquard
  • 1,665
  • 2
  • 12
  • 17