[libc-commits] [libc] [libc] Refactor getopt to use standard reset and internal test hook (PR #197644)

Alexey Samsonov via libc-commits libc-commits at lists.llvm.org
Thu May 14 11:58:30 PDT 2026


================
@@ -16,8 +16,15 @@
 namespace LIBC_NAMESPACE_DECL {
 
 namespace impl {
-void set_getopt_state(char **, int *, int *, unsigned *, int *, FILE *);
+extern "C" {
+extern char *optarg;
+extern int optind;
+extern int optopt;
+extern int opterr;
 }
+} // namespace impl
+
+void __llvm_libc_getopt_set_errorstream(FILE *);
----------------
vonosmas wrote:

FWIW you might not even need `__llvm_libc_` prefix then, since you're only accessing this function through llvm-libc namespace anyway.

https://github.com/llvm/llvm-project/pull/197644


More information about the libc-commits mailing list