iperf icon indicating copy to clipboard operation
iperf copied to clipboard

fix: GCC 15 / C23 compatibility — uint, u_char, _DEFAULT_SOURCE

Open texasich opened this issue 6 months ago • 2 comments

GCC 15 defaults to -std=gnu23 (C23), which removes uint and u_char from <sys/types.h> and no longer implicitly defines _DEFAULT_SOURCE. This hides POSIX functions like daemon(3), gai_strerror(3), fileno(3), getaddrinfo(3), and others behind feature-test macros.

Changes:

  • src/iperf.h: Add typedef unsigned int uint compatibility fallback
  • src/iperf_config.h.in: Define _DEFAULT_SOURCE globally so all files that include it pick it up
  • src/iperf_client_api.c, iperf_server_api.c, iperf_tcp.c: Add _DEFAULT_SOURCE before system headers (these files include system headers before iperf_config.h)
  • src/units.c: Replace u_char with unsigned char in a toupper() cast

Tested:

  • ✅ gcc -std=c2x -Werror — clean build (C23 mode)
  • ✅ Default flags — clean build (no regression)

Fixes #1838.

texasich avatar May 08 '26 00:05 texasich

Thanks for the PR! We'll take a look at this.

bmah888 avatar May 12 '26 14:05 bmah888

👋 Gentle nudge — just following up on this GCC 15 / C23 compatibility PR. Happy to address any feedback or make adjustments. Thanks!

texasich avatar May 19 '26 03:05 texasich