package/make: fix conflicting prototypes for getenv and getopt
PATCH v3 1/1 package/make: fix conflicting prototypes for getenv and getopt
GCC 15 defaults to C23, which rejects old-style K&R empty parameter list declarations that conflict with typed prototypes in system headers. This is particularly visible when using non-glibc C libraries (e.g. musl).
Fixes:lib/fnmatch.c:124:14: error: conflicting types for 'getenv'; have 'char *(void)'
| 124 | extern char *getenv (); | | ^~~~~~
Fix getenv() declarations in lib/fnmatch.c and src/getopt.c, and fix getopt() declarations in src/getopt.h to match the prototypes in <stdlib.h> and <unistd.h>.
Upstream: https://lists.gnu.org/archive/html/bug-make/2025-03/msg00032.html
---
v2 -> v3:
- Fix whitespace and indentation (check-package)
v1 -> v2:
- Add Upstream: tag with link to bug-make mailing list (Marcus)
- Include specific GCC 15 error log in commit message
- Improve commit description with more technical context
- Update patch headers to standard format
--- ...ing-prototypes-for-getenv-and-getopt.patch | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 package/make/0001-fix-conflicting-prototypes-for-getenv-and-getopt.patch
package/make/0001-fix-conflicting-prototypes-for-getenv-and-getopt.patch new file +70 -0
@@ -0,0 +1,70 @@ +From b64b62d00cb64b62d00cb64b62d00cb64b62d00c Mon Sep 17 00:00:00:00 2001 +From: Shubham Chakraborty <[email protected]> +Date: Sat, 21 Feb 2026 12:00:00 +0000 +Subject: [PATCH] fix conflicting prototypes for getenv and getopt + +GCC 15 defaults to C23, which rejects old-style K&R empty parameter +list declarations that conflict with typed prototypes in system headers. + +Fix getenv() declarations in lib/fnmatch.c and src/getopt.c, and +fix getopt() declarations in src/getopt.h to match the prototypes +in <stdlib.h> and <unistd.h>. + +This fixes build errors like: +error: conflicting types for 'getenv'; have 'char *(void)' + +Upstream: https://lists.gnu.org/archive/html/bug-make/2025-03/msg00032.html +Signed-off-by: Shubham Chakraborty <[email protected]> +--- + lib/fnmatch.c | 2 +- + src/getopt.c | 2 +- + src/getopt.h | 4 ++-- + 3 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/lib/fnmatch.c b/lib/fnmatch.c +--- a/lib/fnmatch.c ++++ b/lib/fnmatch.c +@@ -121,7 +121,7 @@ + whose names are inconsistent. */ + + # if !defined _LIBC && !defined getenv +-extern char *getenv (); ++extern char *getenv (const char *__name); + # endif + + # ifndef errno +diff --git a/src/getopt.c b/src/getopt.c +--- a/src/getopt.c ++++ b/src/getopt.c +@@ -202,7 +202,7 @@ + whose names are inconsistent. */ + + #ifndef getenv +-extern char *getenv (); ++extern char *getenv (const char *__name); + #endif + + static char * +diff --git a/src/getopt.h b/src/getopt.h +--- a/src/getopt.h ++++ b/src/getopt.h +@@ -102,7 +102,7 @@ + errors, only prototype getopt for the GNU C library. */ + extern int getopt (int argc, char *const *argv, const char *shortopts); + #else /* not __GNU_LIBRARY__ */ +-extern int getopt (); ++extern int getopt (int argc, char *const *argv, const char *shortopts); + #endif /* __GNU_LIBRARY__ */ + extern int getopt_long (int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind); +@@ -116,7 +116,7 @@ + const struct option *longopts, int *longind, + int long_only); + #else /* not __STDC__ */ +-extern int getopt (); ++extern int getopt (int argc, char *const *argv, const char *shortopts); + extern int getopt_long (); + extern int getopt_long_only (); + +-- +2.43.0
Signature · 6 lines
2.53.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot