fix: add u_char/u_short/u_int typedefs for GCC 15 / C23 compatibility#306
fix: add u_char/u_short/u_int typedefs for GCC 15 / C23 compatibility#306texasich wants to merge 2 commits into
Conversation
Under GCC 15 the default C standard is -std=gnu23 (C23), which removes u_char, u_short, and u_int from <sys/types.h>. The libpcap <pcap.h> header and nethogs own decpcap.h both use these types, causing a cascade of "unknown type name" errors. Add compatibility typedefs guarded by #ifndef before the pcap.h include so they are visible both to libpcap and to decpcap.h. Fixes raboof#287.
Interesting. Is that what pcap recommends doing or do they just not support this version? |
|
Thanks for the review! I checked libpcap upstream — they haven't addressed C23 compatibility at all yet. Zero issues, PRs, or commits in The Happy to also file an upstream issue at |
That would probably be nice! In the mean time I'll merge this workaround. |
|
Oh maybe you could add a link to the upstream issue in the comment? |
|
Upstream issue filed: the-tcpdump-group/libpcap#1679 — requesting libpcap add u_char/u_short/u_int compatibility typedefs for C23/GCC 15. |
|
(This, BTW, is not a C23 issue, it's a "GNU libc when compiling with C23 issue" - no version of C has |
Per maintainer request (PR raboof#306), reference the upstream libpcap issue tracking C23 compatibility for u_char/u_short/u_int types. Upstream: the-tcpdump-group/libpcap#1679
Under GCC 15 the default C standard is
-std=gnu23(C23), which removesu_char,u_short, andu_intfrom<sys/types.h>. The libpcap<pcap.h>header and nethogs' owndecpcap.hboth use these types, causing a cascade of "unknown type name" errors.This adds compatibility typedefs guarded by
#ifndefbefore thepcap.hinclude so they are visible both to libpcap and to the rest ofdecpcap.h.Tested: builds cleanly with GCC 13
-std=c2x(the GCC 13 name for C23 mode) and-D_DEFAULT_SOURCE, and with the default-std=c++14build.Fixes #287.