c - passing argument from incompatible pointer type -


    static struct dll_wifi_state **dll_states;      enum dll_type {       dll_unsupported,       dll_ethernet,       dll_wifi     };      struct dll_state {       enum dll_type type;        union {         struct dll_eth_state *ethernet;         struct dll_wifi_state *wifi;       } data;     };      static struct dll_state *dll_states = null;  struct dll_wifi_state {   int link;    // pointer function called pass data next layer.   up_from_dll_fn_ty nl_callback;    bool is_ds;  }; 

this method pointer being passed in dll_wifi_state struct.

static void up_from_dll(int link, const char *data, size_t length) { //some code here } 

in other file, calling method

void reboot_accesspoint() {   // require each node have different stream of random numbers.   cnet_srand(nodeinfo.time_of_day.sec + nodeinfo.nodenumber);    // provide required event handlers.   check(cnet_set_handler(ev_physicalready, physical_ready, 0));    // prepare talk via our wireless connection.   check(cnet_set_wlan_model(my_wlan_model));    // setup our data link layer instances.   dll_states = calloc(nodeinfo.nlinks + 1, sizeof(struct dll_state));    (int link = 0; link <= nodeinfo.nlinks; ++link) {     switch (linkinfo[link].linktype) {       case lt_loopback:         dll_states[link].type = dll_unsupported;         break;        case lt_wan:         dll_states[link].type = dll_unsupported;         break;        case lt_lan:         dll_states[link].type = dll_ethernet;         dll_states[link].data.ethernet = dll_eth_new_state(link, up_from_dll);         break;        case lt_wlan:         dll_states[link].type = dll_wifi;         dll_states[link].data.wifi = dll_wifi_new_state(link,                                                         up_from_dll,                                                         true /* is_ds */);         break;     }   }    // printf("reboot_accesspoint() complete.\n"); } 

it works fine this, want add argument i.e. up_from_dll((int link, const char *data, size_t length, int seq). , add argument, following error starts coming up

ap.c:153: warning: passing argument 2 of ‘dll_wifi_new_state’ incompatible pointer type 

is there way of adding argument method without getting error ??? bad pointers :(

any appreciated.

line 153 :

dll_states[link].data.wifi = dll_wifi_new_state(link,                                                             up_from_dll,                                                             true /* is_ds */); 

and method

struct dll_wifi_state *dll_wifi_new_state(int link,                                           up_from_dll_fn_ty callback,                                           bool is_ds) {   // ensure given link exists , wlan link.   if (link > nodeinfo.nlinks || linkinfo[link].linktype != lt_wlan)     return null;    // allocate memory state.   struct dll_wifi_state *state = calloc(1, sizeof(struct dll_wifi_state));    // check whether or not allocation successful.   if (state == null)     return null;    // initialize members of structure.   state->link = link;   state->nl_callback = callback;   state->is_ds = is_ds;    return state; } 

i haven't changed else apart adding new parameter up_from_dll.

the second parameter dll_wifi_new_state up_from_dll_fn_ty callback.

it's not in code listing right now, up_from_dll_fn_ty typedef saying up_from_dll_fn_ty function pointer specific parameters (which don't include int seq)

when updated up_from_dll different parameters, no longer matches type specified up_from_dll_fn_ty , expected second parameter dll_wifi_new_state. you'll need add parameter up_from_dll_fn_ty , should good.

if post definition of up_from_dll_fn_ty, make question have information , allow me more if still need it.

you're looking like:

typedef void (*up_from_dll_fn_ty)(int link, const char *data, size_t length); 

and change to

typedef void (*up_from_dll_fn_ty)(int link, const char *data, size_t length, int seq); 

here's link question has information creating typedefs function pointers:

understanding typedefs function pointers in c


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -