我对C编程很陌生,所以想知道是否有人可以帮助解决这些问题。 (我正在尝试编译别人的代码,我无法对这些代码进行编码)
src/connection.c:79:9: warning: implicit declaration of function 'close' [-Wimplicit-function-declaration
close(conn->fd);
src/main.c: In function 'main':
src/main.c:37:16: warning: implicit declaration of function 'inet_addr' [-Wimplicit-function-declaration]
addrs[0] = inet_addr("192.168.252.20"); // Address to bind to
src/server.c: In function 'server_queue_telnet':
src/server.c:93:9: warning: implicit declaration of function 'sleep' [-Wimplicit-function-declaration]
sleep(1);
src/telnet_info.c: In function 'telnet_info_parse':
src/telnet_info.c:59:12: warning: implicit declaration of function 'inet_addr' [-Wimplicit-function-decla
addr = inet_addr(addr_str);
src/telnet_info.c:60:12: warning: implicit declaration of function 'htons' [-Wimplicit-function-declarati
port = htons(atoi(port_str));
src/server.c: In function 'server_queue_telnet':
src/server.c:93:9: warning: implicit declaration of function 'sleep' [-Wimplicit-function-declaration]
sleep(1);
src/util.c:94:9: warning: implicit declaration of function 'close' [-Wimplicit-function-declaration]
close(fd);
src/util.c: In function 'util_trim':
src/util.c:161:11: warning: implicit declaration of function 'isspace' [-Wimplicit-function-declaration]
while(isspace(*str))
我设法通过在相应的文件中包含以下缺少的include语句来修复上述警告。
include <unistd.h>
include <arpa/inet.h>
include <ctype.h>
然而,以下警告仍然存在,我无法解决哪些包含语句丢失。当我 man ntohs , man htons 和 man rand 时,我看不到任何应该包含在connection.c和util.c中的指定库文件
src/connection.c: In function 'connection_close':
src/connection.c:62:17: warning: implicit declaration of function 'ntohs' [-Wimplicit-function-declaratio
ntohs(conn->info.port),
src/connection.c: In function 'connection_consume_arch':
src/connection.c:485:35: warning: implicit declaration of function 'htons' [-Wimplicit-function-declarati
ehdr->e_machine = htons(ehdr->e_machine);
src/util.c: In function 'util_socket_and_bind':
src/util.c:77:18: warning: implicit declaration of function 'rand' [-Wimplicit-function-declaration]
start_addr = rand() % srv->bind_addrs_len;