(WIP) Cleanup includes, enhance portability
Found by: michaelortmann Patch by: michaelortmann Fixes:
One-line summary:
sys/socket.h and netinet/in.h are included by eggdrop.h, so, anything including eggdrop.h directly or indirectly doesnt need to include sys/socket.h explicitely.
Additional description (if needed):
by indirectly, i mean that main.h includes eggdrop.h and mod/module.h includes main.h. Cleaning up includes enhances portability. Im esp. looking at any socket includes here, because, should we ever be able to port eggdrop to mingw, it would be less work to replace those includes with winsock.h.
WIP, because i will look at arpa/inet.h and maybe other includes also.
Test cases demonstrating functionality (if applicable): The following will not be part of this PR, but thats, what inspired this PR, cross compiling for x86_64-w64-mingw32:
$ sudo pacman -S mingw-w64-gcc
$ https://prdownloads.sourceforge.net/tcl/tcl8.6.12-src.tar.gz
$ tar -zxvf tcl8.6.12-src.tar.gz
$ cd tcl8.6.12/win
$ ./configure --host=x86_64-w64-mingw32 --prefix=/home/michael/opt/tcl-8.6.12-w64
$ make
$ make install
[...]
$ ./configure --host=x86_64-w64-mingw32 --with-tcllib=/home/michael/opt/tcl-8.6.12-w64/lib/libtcl86.dll.a --with-tclinc=/home/michael/opt/tcl-8.6.12-w64/include/tcl.h
$ make config
now, with patching some more network includes like this and use winsock.h switch in eggdrop.h we are going somewhere:
$ make static
make[1]: Entering directory '/home/michael/projects/eggdrop5/eggdrop/src/mod'
make[2]: Entering directory '/home/michael/projects/eggdrop5/eggdrop/src/mod/assoc.mod'
x86_64-w64-mingw32-gcc -g -O2 -pipe -Wall -I. -I../../.. -I../../.. -I../../../src/mod -DHAVE_CONFIG_H -I/home/michael/opt/tcl-8.6.12-w64/include -DSTATIC -DMAKING_MODS -c .././assoc.mod/assoc.c && mv -f assoc.o ../
In file included from ../../../src/main.h:101,
from ../../../src/mod/module.h:28,
from .././assoc.mod/assoc.c:27:
.././assoc.mod/assoc.c: In function ‘botnet_send_assoc’:
../../../src/users.h:133:23: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
133 | #define bot_flags(u) ((long)get_user(&USERENTRY_BOTFL, (u)))
| ^
.././assoc.mod/assoc.c:54:11: note: in expansion of macro ‘bot_flags’
54 | !(bot_flags(dcc[idx2].user) & BOT_ISOLATE))
| ^~~~~~~~~
.././assoc.mod/assoc.c: In function ‘link_assoc’:
../../../src/users.h:133:23: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
133 | #define bot_flags(u) ((long)get_user(&USERENTRY_BOTFL, (u)))
| ^
.././assoc.mod/assoc.c:76:11: note: in expansion of macro ‘bot_flags’
76 | if (!(bot_flags(dcc[idx].user) & BOT_ISOLATE)) {
| ^~~~~~~~~
.././assoc.mod/assoc.c: In function ‘zapf_assoc’:
../../../src/users.h:133:23: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
133 | #define bot_flags(u) ((long)get_user(&USERENTRY_BOTFL, (u)))
| ^
.././assoc.mod/assoc.c:317:23: note: in expansion of macro ‘bot_flags’
317 | if ((idx >= 0) && !(bot_flags(dcc[idx].user) & BOT_ISOLATE)) {
| ^~~~~~~~~
make[2]: Leaving directory '/home/michael/projects/eggdrop5/eggdrop/src/mod/assoc.mod'
make[2]: Entering directory '/home/michael/projects/eggdrop5/eggdrop/src/mod/blowfish.mod'
x86_64-w64-mingw32-gcc -g -O2 -pipe -Wall -I. -I../../.. -I../../.. -I../../../src/mod -DHAVE_CONFIG_H -I/home/michael/opt/tcl-8.6.12-w64/include -DSTATIC -DMAKING_MODS -c .././blowfish.mod/blowfish.c && mv -f blowfish.o ../
make[2]: Leaving directory '/home/michael/projects/eggdrop5/eggdrop/src/mod/blowfish.mod'
make[2]: Entering directory '/home/michael/projects/eggdrop5/eggdrop/src/mod/channels.mod'
x86_64-w64-mingw32-gcc -g -O2 -pipe -Wall -I. -I../../.. -I../../.. -I../../../src/mod -DHAVE_CONFIG_H -I/home/michael/opt/tcl-8.6.12-w64/include -DSTATIC -DMAKING_MODS -c .././channels.mod/channels.c && mv -f channels.o ../
make[2]: Leaving directory '/home/michael/projects/eggdrop5/eggdrop/src/mod/channels.mod'
make[2]: Entering directory '/home/michael/projects/eggdrop5/eggdrop/src/mod/console.mod'
x86_64-w64-mingw32-gcc -g -O2 -pipe -Wall -I. -I../../.. -I../../.. -I../../../src/mod -DHAVE_CONFIG_H -I/home/michael/opt/tcl-8.6.12-w64/include -DSTATIC -DMAKING_MODS -c .././console.mod/console.c && mv -f console.o ../
make[2]: Leaving directory '/home/michael/projects/eggdrop5/eggdrop/src/mod/console.mod'
make[2]: Entering directory '/home/michael/projects/eggdrop5/eggdrop/src/mod/ctcp.mod'
x86_64-w64-mingw32-gcc -g -O2 -pipe -Wall -I. -I../../.. -I../../.. -I../../../src/mod -DHAVE_CONFIG_H -I/home/michael/opt/tcl-8.6.12-w64/include -DSTATIC -DMAKING_MODS -c .././ctcp.mod/ctcp.c && mv -f ctcp.o ../
.././ctcp.mod/ctcp.c: In function ‘ctcp_CHAT’:
.././ctcp.mod/ctcp.c:144:10: error: ‘INET6_ADDRSTRLEN’ undeclared (first use in this function)
144 | char s[INET6_ADDRSTRLEN];
| ^~~~~~~~~~~~~~~~
.././ctcp.mod/ctcp.c:144:10: note: each undeclared identifier is reported only once for each function it appears in
.././ctcp.mod/ctcp.c:144:8: warning: unused variable ‘s’ [-Wunused-variable]
144 | char s[INET6_ADDRSTRLEN];
| ^
make[2]: *** [Makefile:17: ../ctcp.o] Error 1
make[2]: Leaving directory '/home/michael/projects/eggdrop5/eggdrop/src/mod/ctcp.mod'
make[1]: *** [Makefile:67: ctcp.mod_o] Error 2
make[1]: Leaving directory '/home/michael/projects/eggdrop5/eggdrop/src/mod'
make: *** [Makefile:271: static] Error 2