I get an error when trying to assign a value to a pointer.
I have defined 2 structs:
typedef struct {
struct player *next; //pointers
struct player *prev;
} player;
typedef struct {
player onMe; //object
} field;
later in the code, I create an instance of the struct "player p" and try to use it: fields[][] is an array that holds structs of the type field.
fields[p.x][p.y].onMe = *(p.next);
(*p.prev).next = &p.next;
in these cases i get "error: dereferencing pointer to incomplete type" I also tried (&p.next) but has the same result.
fields[x][y].onMe.prev = (&p);
in this case i get "warning: assignment from incompatible pointer type [enabled by default]"
Can someone tell me what I'm doing wrong?
You don't declare struct player
anywhere so the definition of the struct is incomplete. Try
typedef struct player_s {
struct player_s *prev;
struct player_s *next;
} player;