Skip to content

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

Open
texasich wants to merge 1 commit into
esnet:masterfrom
texasich:fix-gcc15-c23-compat
Open

fix: GCC 15 / C23 compatibility — uint, u_char, _DEFAULT_SOURCE#2035
texasich wants to merge 1 commit into
esnet:masterfrom
texasich:fix-gcc15-c23-compat

Conversation

@texasich
Copy link
Copy Markdown

@texasich texasich commented May 8, 2026

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.

GCC 15 defaults to -std=gnu23 (C23), which:
- Removes uint and u_char from <sys/types.h>
- No longer implicitly defines _DEFAULT_SOURCE, hiding 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` fallback
- src/iperf_config.h.in: define _DEFAULT_SOURCE globally
- src/iperf_client_api.c, iperf_server_api.c, iperf_tcp.c:
  add _DEFAULT_SOURCE define before system headers (these
  files include system headers before iperf_config.h)
- src/units.c: s/u_char/unsigned char/ for toupper() cast

Tested: builds cleanly with gcc -std=c2x -Werror (GCC 13
name for C23 mode), and with default flags.

Fixes esnet#1838
@bmah888
Copy link
Copy Markdown
Contributor

bmah888 commented May 12, 2026

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fails To Build From Source with GCC-15

2 participants