Skip to content

C99 compatibility fixes#35

Open
fweimer-rh wants to merge 2 commits into
jonasob:masterfrom
fweimer-rh:c99
Open

C99 compatibility fixes#35
fweimer-rh wants to merge 2 commits into
jonasob:masterfrom
fweimer-rh:c99

Conversation

@fweimer-rh

Copy link
Copy Markdown

Avoid implicit declarations of inet_pton, exit.  Include <arpa/inet.h>
for the glibc declaration.  Return from main instead of calling exit.
This avoids compilation errors with future compilers.
So that it can be called from the main function.  This avoids a
compilation error with future compilers.
@HaoLiHaiO

Copy link
Copy Markdown

I came here to fix this issue because I got it from the AUR on Arch Linux and timeout_init() doesn't compile anymore. It's been apparently been fixed but never merged.

@jonasob jonasob left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good set of C99 compatibility fixes. All changes look correct:

  1. arpa/inet.h detection and includeinet_pton is declared in <arpa/inet.h> on POSIX systems. Adding the AC_CHECK_HEADERS entry and the conditional include in the configure test is the right fix. Without this, implicit declaration of inet_pton is an error in C99+.

  2. exit()return in configure test main() — Avoids implicit declaration of exit() (which requires <stdlib.h>). Using return from main() is cleaner and doesn't need an extra include.

  3. timeout_init()timeout_init(void) — In C99+, f() means unspecified parameters (and is deprecated), while f(void) explicitly means no parameters. The matching declaration added to include/utils.h keeps the header and implementation in sync.

All three changes are minimal, correct, and necessary for building with modern C compilers (GCC 14+, Clang 16+) that default to C17/C23 where implicit function declarations and implicit ints are errors.


Generated by Claude Code

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.

3 participants