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

时间:2022-02-28 21:41:24

I'm getting an error (error: dereferencing pointer to incomplete type ) with addData->s = s and addData->type = type, and I'm not sure why... it seems like it should work to me (I'm a bit rusty with C, however)

我得到了一个错误(错误:不完整类型的解除引用指针)。这对我来说似乎行得通(不过我对C有点生疏了)

Here's the code:

这是代码:

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

...

I have syment as

我syment

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

Thanks!

谢谢!

1 个解决方案

#1


1  

Try changing

试着改变

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

to

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

Pointer overload and this is not Crufts (Pointer is a dog, Crufts is a dog show).

指针重载,这不是Crufts(指针是dog, Crufts是dog show)。

#1


1  

Try changing

试着改变

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

to

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

Pointer overload and this is not Crufts (Pointer is a dog, Crufts is a dog show).

指针重载,这不是Crufts(指针是dog, Crufts是dog show)。