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                                        
{

};

person Yaroslav Kirillov    schedule 23.10.2016    source источник


Ответы (1)


Ошибка возникает из-за смешения при объявлении 'struct Raw_data_struct'. Вы можете посмотреть сообщение typedef struct vs struct Definitions [дубликат].

Чтобы объявить свою структуру, вы должны использовать:

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;

Если вы хотите объявить и структуру, и typedef, вам нужно использовать:

typedef struct Raw_data_struct {
  uint8_t time;
  uint8_t type;
  uint8_t phase;
  uint8_t status;
} Getst_struct;  
person J. Piquard    schedule 23.10.2016