Closed truelv closed 3 years ago
Something like below should help you. Would be nice to have it in the repository also. `--- mdns.c 2021-03-03 14:28:10.985312438 +0100 +++ mdns.c 2021-03-04 10:43:52.402920592 +0100 @@ -15,6 +15,8 @@
+ +#include <sys/select.h>
static char addrbuffer[64]; `
Thanks for your kindly reply! But it can't be completely solved,because some macros are not existed on linux,they are just for windows,such as NI_MAXHOST,NI_MAXSERV ...
Below is the whole compile errors: [wangya@localhost mdns-1.3]$ gcc -o mdns mdns.c -std=c99 In file included from mdns.c:8: mdns.h: In function ‘mdns_socket_setup_ipv4’: mdns.h:311: error: storage size of ‘req’ isn’t known mdns.h: In function ‘mdns_string_equal’: mdns.h:505: warning: implicit declaration of function ‘strncasecmp’ mdns.c: In function ‘ipv4_address_to_string’: mdns.c:44: error: ‘NI_MAXHOST’ undeclared (first use in this function) mdns.c:44: error: (Each undeclared identifier is reported only once mdns.c:44: error: for each function it appears in.) mdns.c:45: error: ‘NI_MAXSERV’ undeclared (first use in this function) mdns.c:46: warning: implicit declaration of function ‘getnameinfo’ mdns.c:47: error: ‘NI_NUMERICSERV’ undeclared (first use in this function) mdns.c:47: error: ‘NI_NUMERICHOST’ undeclared (first use in this function) mdns.c: In function ‘ipv6_address_to_string’: mdns.c:66: error: ‘NI_MAXHOST’ undeclared (first use in this function) mdns.c:67: error: ‘NI_MAXSERV’ undeclared (first use in this function) mdns.c:69: error: ‘NI_NUMERICSERV’ undeclared (first use in this function) mdns.c:69: error: ‘NI_NUMERICHOST’ undeclared (first use in this function) mdns.c: In function ‘main’: mdns.c:661: warning: implicit declaration of function ‘gethostname’
those are not Windows specific macros, see
https://www.man7.org/linux/man-pages/man3/getnameinfo.3.html
try adding -D_GNU_SOURCE to your compile command line
It works,thanks very much!
[wangya@localhost mdns-1.3]$ cat /proc/version Linux version 2.6.32-431.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 03:15:09 UTC 2013
[wangya@localhost mdns-1.3]$ gcc -o mdns mdns.c -std=c99 In file included from mdns.c:8: mdns.h: In function ‘mdns_socket_setup_ipv4’: mdns.h:311: error: storage size of ‘req’ isn’t known mdns.h: In function ‘mdns_string_equal’: mdns.h:505: warning: implicit declaration of function ‘strncasecmp’ mdns.c: In function ‘ipv4_address_to_string’: mdns.c:43: error: ‘NI_MAXHOST’ undeclared (first use in this function) mdns.c:43: error: (Each undeclared identifier is reported only once mdns.c:43: error: for each function it appears in.) mdns.c:44: error: ‘NI_MAXSERV’ undeclared (first use in this function) mdns.c:45: warning: implicit declaration of function ‘getnameinfo’ mdns.c:46: error: ‘NI_NUMERICSERV’ undeclared (first use in this function) mdns.c:46: error: ‘NI_NUMERICHOST’ undeclared (first use in this function) mdns.c: In function ‘ipv6_address_to_string’: mdns.c:65: error: ‘NI_MAXHOST’ undeclared (first use in this function) mdns.c:66: error: ‘NI_MAXSERV’ undeclared (first use in this function) mdns.c:68: error: ‘NI_NUMERICSERV’ undeclared (first use in this function) mdns.c:68: error: ‘NI_NUMERICHOST’ undeclared (first use in this function) mdns.c: In function ‘send_dns_sd’: mdns.c:482: error: storage size of ‘timeout’ isn’t known mdns.c:487: error: ‘fd_set’ undeclared (first use in this function) mdns.c:487: error: expected ‘;’ before ‘readfs’ mdns.c:488: warning: implicit declaration of function ‘FD_ZERO’ mdns.c:488: error: ‘readfs’ undeclared (first use in this function) mdns.c:492: warning: implicit declaration of function ‘FD_SET’ mdns.c:496: warning: implicit declaration of function ‘select’ mdns.c:499: warning: implicit declaration of function ‘FD_ISSET’ mdns.c: In function ‘send_mdns_query’: mdns.c:544: error: storage size of ‘timeout’ isn’t known mdns.c:549: error: ‘fd_set’ undeclared (first use in this function) mdns.c:549: error: expected ‘;’ before ‘readfs’ mdns.c:550: error: ‘readfs’ undeclared (first use in this function) mdns.c: In function ‘service_mdns’: mdns.c:605: error: ‘fd_set’ undeclared (first use in this function) mdns.c:605: error: expected ‘;’ before ‘readfs’ mdns.c:606: error: ‘readfs’ undeclared (first use in this function) mdns.c: In function ‘main’: mdns.c:660: warning: implicit declaration of function ‘gethostname’