contiki-os / contiki

The official git repository for Contiki, the open source OS for the Internet of Things
http://www.contiki-os.org/
Other
3.71k stars 2.58k forks source link

Compilation Error while creating structure in rpl-icmp6.c. I am trying to create a structure that stores ip addresses of the nodes from which it is receiving DIS message. #2540

Open abhiverma866 opened 5 years ago

abhiverma866 commented 5 years ago

typedef struct f { uip_ipaddr_t from = &UIP_IP_BUF->srcipaddr; int x; } faltu;

Error: ../../../core/net/rpl/rpl-icmp6.c:106:20: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘attribute’ before ‘=’ token

greg-king5 commented 5 years ago
typedef struct f {
    uip_ipaddr_t from = &UIP_IP_BUF->srcipaddr;
    int x;
} faltu;

Error: ../../../core/net/rpl/rpl-icmp6.c:106:20: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘attribute’ before ‘=’ token

That code tries to do two different things at the same time. It tries to create a type-definition -- and create a variable within that type. You must create them with separate statements.

typedef struct f {
    uip_ipaddr_t addr;
    int x;
} faltu;

...

    faltu from = {
        &UIP_IP_BUF->srcipaddr;
    };
...