简体   繁体   中英

C: error: dereferencing pointer to incomplete type

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)

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

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

Thanks!

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM