From 17970a06477839716d008091065de75f6755819f Mon Sep 17 00:00:00 2001 From: Zhanybek Date: Thu, 7 May 2026 23:30:28 +0000 Subject: [PATCH 1/2] fix: add u_char/u_short/u_int typedefs for GCC 15 / C23 compatibility Under GCC 15 the default C standard is -std=gnu23 (C23), which removes u_char, u_short, and u_int from . The libpcap 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 #287. --- src/decpcap.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/decpcap.h b/src/decpcap.h index 6d2c86f..460fd5d 100644 --- a/src/decpcap.h +++ b/src/decpcap.h @@ -22,6 +22,19 @@ #ifndef __DECPCAP_H #define __DECPCAP_H +/* Compatibility typedefs — u_char/u_short/u_int were removed + from in C23 (GCC 15 default -std=gnu23). + Must come before because libpcap uses these types. */ +#ifndef u_char +typedef unsigned char u_char; +#endif +#ifndef u_short +typedef unsigned short u_short; +#endif +#ifndef u_int +typedef unsigned int u_int; +#endif + #include #include #include From 84ee12dd0923029df536dc2761cc6cbaf0e6ac20 Mon Sep 17 00:00:00 2001 From: Zhanybek Date: Mon, 11 May 2026 14:10:44 +0000 Subject: [PATCH 2/2] docs: add upstream libpcap C23 compat issue link to typedef comment Per maintainer request (PR #306), reference the upstream libpcap issue tracking C23 compatibility for u_char/u_short/u_int types. Upstream: https://github.com/the-tcpdump-group/libpcap/issues/1679 --- src/decpcap.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/decpcap.h b/src/decpcap.h index 460fd5d..a65df02 100644 --- a/src/decpcap.h +++ b/src/decpcap.h @@ -24,7 +24,8 @@ /* Compatibility typedefs — u_char/u_short/u_int were removed from in C23 (GCC 15 default -std=gnu23). - Must come before because libpcap uses these types. */ + Must come before because libpcap uses these types. + Upstream libpcap C23 compat: https://github.com/the-tcpdump-group/libpcap/issues/1679 */ #ifndef u_char typedef unsigned char u_char; #endif