Skip to content

Commit

Permalink
Merge pull request #129 from musicinmybrain/c23
Browse files Browse the repository at this point in the history
Fix building with GCC15 as C23
  • Loading branch information
vfonov authored Jan 16, 2025
2 parents a608a1b + 5b39cd2 commit d84ed48
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions libcommon/ParseArgv.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ ParseLong(const char *argPtr, char **endPtr)
* Process an argv array according to a table of expected
* command-line options. See the manual page for more details.
*
* argcPtr: Number of arguments in argv. Modified to hold # args left in argv
* at end.
*
* argv: Array of arguments. Modified to hold those that couldn't be processed
* here.
*
* argTable: Array of option descriptions
*
* flags: Or'ed combination of various flag bits, such as ARGV_NO_DEFAULTS.
*
* Results:
* The return value is a Boolean value with non-zero indicating an
* error.
Expand All @@ -126,14 +136,7 @@ ParseLong(const char *argPtr, char **endPtr)
*/

int
ParseArgv(argcPtr, argv, argTable, flags)
int *argcPtr; /* Number of arguments in argv. Modified
* to hold # args left in argv at end. */
char **argv; /* Array of arguments. Modified to hold
* those that couldn't be processed here. */
ArgvInfo *argTable; /* Array of option descriptions */
int flags; /* Or'ed combination of various flag bits,
* such as ARGV_NO_DEFAULTS. */
ParseArgv(int *argcPtr, char **argv, ArgvInfo *argTable, int flags)
{
ArgvInfo *infoPtr;
/* Pointer to the current entry in the
Expand Down Expand Up @@ -315,7 +318,8 @@ ParseArgv(argcPtr, argv, argTable, flags)
}
break;
case ARGV_FUNC: {
int (*handlerProc)() = (int (*)())(uintptr_t)infoPtr->src;
typedef int (*handlerProcType)(void*, const char*, char*);
handlerProcType handlerProc = (handlerProcType)(uintptr_t)infoPtr->src;

if ((*handlerProc)(infoPtr->dst, infoPtr->key,
argv[srcIndex])) {
Expand All @@ -325,7 +329,8 @@ ParseArgv(argcPtr, argv, argTable, flags)
break;
}
case ARGV_GENFUNC: {
int (*handlerProc)() = (int (*)())(uintptr_t)infoPtr->src;
typedef int (*handlerProcType)(void*, const char*, int, char**);
handlerProcType handlerProc = (handlerProcType)(uintptr_t)infoPtr->src;

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

0 comments on commit d84ed48

Please sign in to comment.