[PATCH] Fix build with C23 compilers on non-glibc systems
Status: Beta
Brought to you by:
selinger
C23 (the default since GCC 15) treats an empty parameter list as
(void). The bundled getopt only prototypes getopt() when
GNU_LIBRARY is defined and declares getenv() without parameters,
so building against e.g. musl fails:
unistd.h:127:5: error: conflicting types for 'getopt'; have 'int(int, char * const*, const char *)'
./include/getopt/getopt.h:150:12: note: previous declaration of 'getopt' with type 'int(void)'
getopt.c:404:21: error: too many arguments to function 'getenv'; expected 0, have 1
Always use the full POSIX prototype for getopt() and give getenv() its
standard prototype.