Skip to content

Commit e43e323

Browse files
FalconEagleTestlevlam
authored andcommitted
tl-parser: fix getenv/getopt prototypes for C23 compatibility
The vendored wgetopt.c/wgetopt.h use K&R-style empty-parameter declarations (extern char *getenv(); / extern int getopt();). Under C23 (GCC 15+ and Clang 16+ default), () means 'no parameters', so calls with arguments are rejected as errors. Fix by adding the correct prototypes: wgetopt.c: extern char *getenv(const char *); wgetopt.h: extern int getopt(int, char *const *, const char *); Verified: wgetopt.c compiles without errors under -std=gnu23 with GCC 15.2 (MSYS2 MinGW64). No CMake changes needed.
1 parent a9966eb commit e43e323

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

td/generate/tl-parser/wgetopt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ in GCC. */
213213
whose names are inconsistent. */
214214

215215
#ifndef getenv
216-
extern char *getenv();
216+
extern char *getenv(const char *);
217217
#endif
218218

219219
static char *

td/generate/tl-parser/wgetopt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ extern int __posix_getopt (int ___argc, char *const *___argv,
168168
# endif
169169
# endif
170170
#else /* not __GNU_LIBRARY__ */
171-
extern int getopt ();
171+
extern int getopt (int, char *const *, const char *);
172172
#endif /* __GNU_LIBRARY__ */
173173

174174
#ifndef __need_getopt

0 commit comments

Comments
 (0)