Skip to contentSkip to conversation

package/make: fix conflicting prototypes for getenv and getopt

PATCH New Rick 1 participant 1 message Feb 19

lore
Share & tools
lore

Rick

author
#0 lore raw

PATCH 1/1 package/make: fix conflicting prototypes for getenv and getopt

Fix build failures with GCC 15 where old-style K&R function declarations conflict with modern prototypes in standard library headers.

Specifically:
- In lib/fnmatch.c and src/getopt.c, getenv() was declared as 'char *getenv ()', conflicting with 'char getenv (const char )' in <stdlib.h>.
- In src/getopt.h, getopt() was declared as 'int getopt ()' in some

    branches, conflicting with 'int getopt(int, char  const [], const char )'
    in <unistd.h>.

These declarations are updated to include proper parameter types to match modern C standards and standard library definitions.

---
 ...ing-prototypes-for-getenv-and-getopt.patch | 41 +++++++++++++++++++
 1 file changed, 41 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 +41 -0
new file mode 100644
index 0000000000..ff6ac6419b
@@ -0,0 +1,41 @@
+--- 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
+--- 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 *
+--- 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 ();
Signature · 6 lines
2.53.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot