类型“u16_t *”的参数与类型“u16_t[2]*”- uIP库的参数不兼容。

时间:2021-04-09 16:31:07

I am trying to initiate a TCP/IP connection using the standard library uIP. This code was taken directly from the manual, which shows how to open a new connection to a specific IP address (in this case my Windows localhost machine).

我正在尝试使用标准库uIP启动一个TCP/IP连接。这段代码直接取自手册,它展示了如何打开一个新的连接到一个特定的IP地址(在这里是我的Windows localhost机器)。

u16_t ipaddr[2];
uip_ipaddr(ipaddr, 127,0,0,1);
uip_connect(ipaddr, HTONS(51719));

But I am getting the following error:

但我得到了以下错误:

argument of type "u16_t *" is incompatible with parameter of type "u16_t [2]*"

shown for the last line (the uip_connect() function). What am I doing wrong? This is literally a cut-and-paste from the uIP reference manual.

显示最后一行(uip_connect()函数)。我做错了什么?这是来自uIP参考手册的剪切粘贴。

2 个解决方案

#1


1  

The function uip_connect() requires an uip_ipaddr_t* type as its first argument.

函数uip_connect()需要一个uip_ipaddr_t*类型作为它的第一个参数。

uip_ipaddr_t is typedefed from uint16_t[2]. You have to pass the address of your array to get uip_ipaddr_t*

uip_ipaddr_t是从uint16_t[2]中输入的。您必须传递数组的地址以获得uip_ipaddr_t*。

#2


1  

Notice that one is a 2D array u16_t [2]* while the other is a one dimensional array u16_t *. They are obviously not compatible.

注意,其中一个是一个2D数组u16_t[2]*,而另一个是一维数组u16_t *。它们显然不兼容。

#1


1  

The function uip_connect() requires an uip_ipaddr_t* type as its first argument.

函数uip_connect()需要一个uip_ipaddr_t*类型作为它的第一个参数。

uip_ipaddr_t is typedefed from uint16_t[2]. You have to pass the address of your array to get uip_ipaddr_t*

uip_ipaddr_t是从uint16_t[2]中输入的。您必须传递数组的地址以获得uip_ipaddr_t*。

#2


1  

Notice that one is a 2D array u16_t [2]* while the other is a one dimensional array u16_t *. They are obviously not compatible.

注意,其中一个是一个2D数组u16_t[2]*,而另一个是一维数组u16_t *。它们显然不兼容。