All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2 1/2] package/which: fix getopt implicit prototype conflicting with system headers
@ 2026-03-09  7:07 Shubham Chakraborty
  2026-03-09  7:07 ` [Buildroot] [PATCH v2 2/2] DEVELOPERS: add Shubham Chakraborty as maintainer of package/which Shubham Chakraborty
  2026-03-09  9:14 ` [Buildroot] [PATCH v2 1/2] package/which: fix getopt implicit prototype conflicting with system headers Thomas Petazzoni via buildroot
  0 siblings, 2 replies; 4+ messages in thread
From: Shubham Chakraborty @ 2026-03-09  7:07 UTC (permalink / raw)
  To: buildroot; +Cc: Thomas Petazzoni, Shubham Chakraborty

Older C standards allowed empty parentheses in function declarations,
but modern C (C23) treats extern int getopt() as equivalent to
extern int getopt(void), which conflicts with the typed prototype
provided by system headers (e.g. musl's unistd.h).

Fix by providing the full prototype in the non-GNU fallback branch,
matching the standard getopt() signature.

Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
Changes in v2:
- Correct commit message title and body
- Use git format-patch format
---
 package/which/0001-fix-getopt-prototype.patch | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 package/which/0001-fix-getopt-prototype.patch

diff --git a/package/which/0001-fix-getopt-prototype.patch b/package/which/0001-fix-getopt-prototype.patch
new file mode 100644
index 0000000000..af9597242f
--- /dev/null
+++ b/package/which/0001-fix-getopt-prototype.patch
@@ -0,0 +1,15 @@
+diff --git a/getopt.h b/getopt.h
+index f080053..f080054 100644
+--- a/getopt.h
++++ b/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);
+ extern int getopt_long_only(int argc, char *const *argv, const char *shortopts, const struct option *longopts,
+-- 
+2.43.0
-- 
2.53.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-09 16:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09  7:07 [Buildroot] [PATCH v2 1/2] package/which: fix getopt implicit prototype conflicting with system headers Shubham Chakraborty
2026-03-09  7:07 ` [Buildroot] [PATCH v2 2/2] DEVELOPERS: add Shubham Chakraborty as maintainer of package/which Shubham Chakraborty
2026-03-09  9:14 ` [Buildroot] [PATCH v2 1/2] package/which: fix getopt implicit prototype conflicting with system headers Thomas Petazzoni via buildroot
2026-03-09 16:43   ` Shubham Chakraborty

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.