C:错误:取消引用指向不完整类型的指针

时间:2013-02-16 05:14:01

标签: c pointers struct

我收到错误(错误:解除指向不完整类型的指针 )使用addData-> s = s和addData-> type = type,我不知道为什么......它似乎应该对我有用(但我对C有点生疏)

以下是代码:

int addSym(char *s, var_type type){
    struct syment* addData=  malloc(sizeof(syment));
    addData->s = s;
    addData->type = type;

...

我有syment as

typedef struct syment_s {
  char *s;
  int offset;
  var_type type;
  struct syment_s *next;
}*syment;

谢谢!

1 个答案:

答案 0 :(得分:1)

尝试更改

typedef struct syment_s {
  char *s;
  int offset;
  var_type type;
  struct syment_s *next;
}*syment;

typedef struct syment_s {
  char *s;
  int offset;
  var_type type;
  struct syment_s *next;
} syment;

指针超载,这不是Crufts(指针是狗,Crufts是狗展)。