Skip to content

Commit d84ed48

Browse files
authored
Merge pull request #129 from musicinmybrain/c23
Fix building with GCC15 as C23
2 parents a608a1b + 5b39cd2 commit d84ed48

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

libcommon/ParseArgv.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ ParseLong(const char *argPtr, char **endPtr)
111111
* Process an argv array according to a table of expected
112112
* command-line options. See the manual page for more details.
113113
*
114+
* argcPtr: Number of arguments in argv. Modified to hold # args left in argv
115+
* at end.
116+
*
117+
* argv: Array of arguments. Modified to hold those that couldn't be processed
118+
* here.
119+
*
120+
* argTable: Array of option descriptions
121+
*
122+
* flags: Or'ed combination of various flag bits, such as ARGV_NO_DEFAULTS.
123+
*
114124
* Results:
115125
* The return value is a Boolean value with non-zero indicating an
116126
* error.
@@ -126,14 +136,7 @@ ParseLong(const char *argPtr, char **endPtr)
126136
*/
127137

128138
int
129-
ParseArgv(argcPtr, argv, argTable, flags)
130-
int *argcPtr; /* Number of arguments in argv. Modified
131-
* to hold # args left in argv at end. */
132-
char **argv; /* Array of arguments. Modified to hold
133-
* those that couldn't be processed here. */
134-
ArgvInfo *argTable; /* Array of option descriptions */
135-
int flags; /* Or'ed combination of various flag bits,
136-
* such as ARGV_NO_DEFAULTS. */
139+
ParseArgv(int *argcPtr, char **argv, ArgvInfo *argTable, int flags)
137140
{
138141
ArgvInfo *infoPtr;
139142
/* Pointer to the current entry in the
@@ -315,7 +318,8 @@ ParseArgv(argcPtr, argv, argTable, flags)
315318
}
316319
break;
317320
case ARGV_FUNC: {
318-
int (*handlerProc)() = (int (*)())(uintptr_t)infoPtr->src;
321+
typedef int (*handlerProcType)(void*, const char*, char*);
322+
handlerProcType handlerProc = (handlerProcType)(uintptr_t)infoPtr->src;
319323

320324
if ((*handlerProc)(infoPtr->dst, infoPtr->key,
321325
argv[srcIndex])) {
@@ -325,7 +329,8 @@ ParseArgv(argcPtr, argv, argTable, flags)
325329
break;
326330
}
327331
case ARGV_GENFUNC: {
328-
int (*handlerProc)() = (int (*)())(uintptr_t)infoPtr->src;
332+
typedef int (*handlerProcType)(void*, const char*, int, char**);
333+
handlerProcType handlerProc = (handlerProcType)(uintptr_t)infoPtr->src;
329334

330335
argc = (*handlerProc)(infoPtr->dst, infoPtr->key,
331336
argc, argv+srcIndex);

0 commit comments

Comments
 (0)