linux 从不兼容的指针类型,从不兼容指针类型传递参数

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;

// A pointer to the function that is called to pass data up to the next layer.

up_from_dll_fn_ty nl_callback;

bool is_ds;

};

这是指针正在dll_wifi_state结构中传递的方法。从不兼容指针类型传递参数

static void up_from_dll(int link, const char *data, size_t length)

{

//some code here

}

在其他文件中,我调用此方法

void reboot_accesspoint()

{

// We require each node to have a different stream of random numbers.

CNET_srand(nodeinfo.time_of_day.sec + nodeinfo.nodenumber);

// Provide the required event handlers.

CHECK(CNET_set_handler(EV_PHYSICALREADY, physical_ready, 0));

// Prepare to 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));

for (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");

}

它工作正常,像这样的,但我想添加另一种说法,即up_from_dll((INT链接,为const char *的数据,为size_t长度,INT SEQ),而一旦我补充这样的说法,下列错误启动上来

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

是否有增加的另一种说法于法没有得到错误???我与指针非常糟糕的一种方式: (

任何帮助将不胜感激。

153线:

dll_states[link].data.wifi = dll_wifi_new_state(link,

up_from_dll,

true /* is_ds */);

和方法

struct dll_wifi_state *dll_wifi_new_state(int link,

up_from_dll_fn_ty callback,

bool is_ds)

{

// Ensure that the given link exists and is a WLAN link.

if (link > nodeinfo.nlinks || linkinfo[link].linktype != LT_WLAN)

return NULL;

// Allocate memory for the state.

struct dll_wifi_state *state = calloc(1, sizeof(struct dll_wifi_state));

// Check whether or not the allocation was successful.

if (state == NULL)

return NULL;

// Initialize the members of the structure.

state->link = link;

state->nl_callback = callback;

state->is_ds = is_ds;

return state;

}

我还没有从增加新的参数,以up_from_dll改变二话不说。

+0

我现在明白了,并用清晰的答案更新我的答案WER。 –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值