ireader / sdk

portable system call(aio/socket/thread/process/lock/event/pipe)
MIT License
426 stars 240 forks source link

build error under Linux #10

Closed smg31 closed 4 years ago

smg31 commented 4 years ago

Hi, I've just found the following compilation error under Linux (Ubuntu under WSL).

gcc -I. -I./include -I../include -DOS_LINUX -DDEBUG -D_DEBUG -Wall -fPIC -g -Wall -fvisibility=hidden -fvisibility=default -c -MMD -MP -MF debug.linux/aio-connect.d -o src/aio-connect.o src/aio-connect.c
In file included from ../include/sockutil.h:4,
                 from src/aio-connect.c:6:
../include/sys/sock.h: In function ‘socket_multicast_join’:
../include/sys/sock.h:1268:5: error: ‘struct ip_mreq’ has no member named ‘imr_ifindex’
 1268 |  imr.imr_ifindex = 0; // any interface
      |     ^
../include/sys/sock.h:1269:32: error: ‘struct ip_mreq’ has no member named ‘imr_address’
 1269 |  inet_pton(AF_INET, local, &imr.imr_address);
      |                                ^
make[1]: *** [../gcc.mk:84: src/aio-connect.o] Error 1

Very small change of the following should resolve the issue.

diff --git a/include/sys/sock.h b/include/sys/sock.h
index 3db2fbf..d4e6f7a 100644
--- a/include/sys/sock.h
+++ b/include/sys/sock.h
@@ -1263,7 +1263,7 @@ static inline int socket_multicast_join(IN socket_t sock, IN const char* group,
    inet_pton(AF_INET, local, &imr.imr_interface);
    return setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char*)&imr, sizeof(imr));
 #else
-   struct ip_mreq imr;
+   struct ip_mreqn imr;
    memset(&imr, 0, sizeof(imr));
    imr.imr_ifindex = 0; // any interface
    inet_pton(AF_INET, local, &imr.imr_address);

Hope the above may be of your help

Best regards, smg31