nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1From 16a1647fc26953fab659de5f55d4c0defdfb894f Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 22 Mar 2025 17:56:19 -0700
4Subject: [PATCH] getopt: Fix signature of getenv function
5
6This happens on musl systems using GCC 15
7
8../which-2.21/getopt.h:106:12: error: conflicting types for 'getopt'; have
9'int(void)'
10 106 | extern int getopt ();
11 | ^~~~~~
12---
13Link: https://lists.gnu.org/archive/html/which-bugs/2025-03/msg00000.html
14 getopt.c | 2 +-
15 getopt.h | 2 +-
16 2 files changed, 2 insertions(+), 2 deletions(-)
17
18diff --git a/getopt.c b/getopt.c
19index 9ac2ed6..7e14270 100644
20--- a/getopt.c
21+++ b/getopt.c
22@@ -205,7 +205,7 @@ static char *posixly_correct;
23 /* Avoid depending on library functions or files
24 whose names are inconsistent. */
25
26-char *getenv();
27+char *getenv(const char*);
28
29 static char *my_index(str, chr) const char *str;
30 int chr;
31diff --git a/getopt.h b/getopt.h
32index f080053..635fc46 100644
33--- a/getopt.h
34+++ b/getopt.h
35@@ -102,7 +102,7 @@ struct option {
36 errors, only prototype getopt for the GNU C library. */
37 extern int getopt(int argc, char *const *argv, const char *shortopts);
38 #else /* not __GNU_LIBRARY__ */
39-extern int getopt();
40+extern int getopt(int, char * const [], const char *);
41 #endif /* __GNU_LIBRARY__ */
42 extern int getopt_long(int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind);
43 extern int getopt_long_only(int argc, char *const *argv, const char *shortopts, const struct option *longopts,
44