[XS] Change in osmo-ggsn[master]: lib/getopt1: declare _getopt_internal()
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ggsn/+/43583?usp=email ) Change subject: lib/getopt1: declare _getopt_internal() ...................................................................... lib/getopt1: declare _getopt_internal() lib/getopt1.c and lib/getopt.c include "getopt.h", but the bundled header is named lib/gnugetopt.h and no lib/getopt.h exists. The include therefore falls through to the system getopt.h. That header declares getopt(), getopt_long() and getopt_long_only(), but not _getopt_internal(), which is private to the GNU implementation, so the two calls in getopt1.c have no declaration in scope. clang 16 and later reject an implicit declaration instead of warning: lib/getopt1.c:72:9: error: call to undeclared function '_getopt_internal'; ISO C99 and later do not support implicit function declarations GNU/Linux never gets there. On glibc, getopt1.c defines ELIDE_CODE and compiles to nothing, because the C library already provides the whole interface. The bundled copy is only really built where the C library is not glibc, which is where the declaration is missing. Declare _getopt_internal() in getopt1.c, matching the K&R definition in getopt.c. Fixing the include to name gnugetopt.h would be the other way, but that header is installed under a different name on purpose and the declaration is the smaller change. Reproduced with clang 17 (Xcode 16) on macOS ARM64; the file compiles clean with the declaration in place. Change-Id: Ia8bfe94dfd1ea1f4b270f1661305d6247dfc361b Signed-off-by: Andrei Gosman <andrei.gosman@gmail.com> --- M lib/getopt1.c 1 file changed, 5 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved laforge: Looks good to me, but someone else must approve diff --git a/lib/getopt1.c b/lib/getopt1.c index c4e4190..9215a27 100644 --- a/lib/getopt1.c +++ b/lib/getopt1.c @@ -52,6 +52,11 @@ #ifndef ELIDE_CODE +/* getopt.c defines this in K&R style; clang 16 and later refuse the + * implicit declaration that the non-glibc branch of gnugetopt.h leaves. */ +extern int _getopt_internal(int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind, int long_only); + /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ -- To view, visit https://gerrit.osmocom.org/c/osmo-ggsn/+/43583?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-ggsn Gerrit-Branch: master Gerrit-Change-Id: Ia8bfe94dfd1ea1f4b270f1661305d6247dfc361b Gerrit-Change-Number: 43583 Gerrit-PatchSet: 2 Gerrit-Owner: Andrei G <andrei.gosman@gmail.com> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge@osmocom.org> Gerrit-Reviewer: pespin <pespin@sysmocom.de>
participants (1)
-
pespin