inet_ntop存在冲突类型

我试图在Msys2 mingw32上编译luasocket。当我运行make时,我收到以下错误信息:

src\inet.h:48:13: error: conflicting types for 'inet_ntop'
48 | const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt);
  |             ^~~~~~~~~
In file included from src\wsocket.h:12,
             from src\socket.h:18,
             from src\inet.h:18,
             from src\luasocket.c:20:
C:/msys64/mingw32/i686-w64-mingw32/include/ws2tcpip.h:451:35: note: previous declaration of 'inet_ntop' was here
451 | WINSOCK_API_LINKAGE LPCSTR WSAAPI InetNtopA(INT Family, LPCVOID pAddr, LPSTR pStringBuf, size_t StringBufSize);

ws2tcpip包含在inet.h文件中。我需要设置一些不同的选项以在mingw中成功编译吗?

点赞
用户5919934
用户5919934

你的 mingw32 环境已经很新了,因此 ws2tcpip.h 中已经有 inet_ntop(),所以 src\inet.h 不需要重新定义它。

尝试从 src\inet.h 中删除 inet_ntop()

如果在链接时出现与 socket 函数相关的未解决符号错误,则可能需要在链接器标志中添加 -lws2_32

2020-06-04 06:23:33