C99 compatibility fixes#35
Conversation
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.
|
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
left a comment
There was a problem hiding this comment.
Good set of C99 compatibility fixes. All changes look correct:
-
arpa/inet.hdetection and include —inet_ptonis declared in<arpa/inet.h>on POSIX systems. Adding theAC_CHECK_HEADERSentry and the conditional include in the configure test is the right fix. Without this, implicit declaration ofinet_ptonis an error in C99+. -
exit()→returnin configure testmain()— Avoids implicit declaration ofexit()(which requires<stdlib.h>). Usingreturnfrommain()is cleaner and doesn't need an extra include. -
timeout_init()→timeout_init(void)— In C99+,f()means unspecified parameters (and is deprecated), whilef(void)explicitly means no parameters. The matching declaration added toinclude/utils.hkeeps 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
Related to: