I am unable to use inet_aton()
to convert an ASCII IP address such as "192.168.0.1"
to a struct in_addr
address in network byte order because I cannot get my code to compile.
I'm working in this file: socket__geeksforgeeks_udp_server_GS_edit_GREAT.c
Here is my build command:
gcc -Wall -Wextra -Werror -O3 -std=c17 \socket__geeksforgeeks_udp_server_GS_edit_GREAT.c -o bin/server \-lm && bin/server
Here is my command and error output:
eRCaGuy_hello_world/c$ gcc -Wall -Wextra -Werror -O3 -std=c17 socket__geeksforgeeks_udp_server_GS_edit_GREAT.c -o bin/server -lm && bin/serversocket__geeksforgeeks_udp_server_GS_edit_GREAT.c: In function ‘main’:socket__geeksforgeeks_udp_server_GS_edit_GREAT.c:159:15: error: implicit declaration of function ‘inet_aton’; did you mean ‘inet_pton’? [-Werror=implicit-function-declaration] retcode = inet_aton("127.0.0.1", &addr_server.sin_addr); ^~~~~~~~~ inet_ptoncc1: all warnings being treated as errors
The part I want to fix is:
implicit declaration of function ‘inet_aton’; did you mean ‘inet_pton’? [-Werror=implicit-function-declaration]
I am including arpa/inet.h
, which contains the declaration for inet_aton()
, at the top of my source file, so I know that is not the problem:
#include <arpa/inet.h>