Search code examples
cpointerscontiki

Assignment from incompatible pointer type -- Contiki C program


This program is being run in Contiki simulator Cooja.

This is the line giving error:

n=(known_interest_list[*i].head_neighbour_list);
  • n is a struct neighbour * (pointer)
  • head_neighbour_list is pointer to head of a list of struct neighbour type elements
  • known_interest_list is an array of structs

The structures are defined as follows:

struct neighbor {
  struct neighbor *next;
  rimeaddr_t addr;
  int last_rssi, last_lqi;
  int count;
  int update_time;
};

struct  known_interest{
    struct neighbour *head_neighbour_list;
    int count;
    int interest_no;
};

struct known_interest known_interest_list[MAX_INTERESTS];

The error is:

uniBroad.c:221:10: warning: assignment from incompatible pointer type [enabled by default]

I know this is a very basic error, but I have absolutely ensured that data types of both sides of assignment statement are same. Still, this error is not getting resolved.


Solution

  • It seems to be an issue with locales ;). Unless you have a typo only here in the question, there are two different struct neighbo[u]r types

    struct neighbour *head_neighbour_list // in the known_interest
    struct neighbor *next // in the struct neighbor itself
    

    There's an extra u in the known_interest