Skip to content

Commit ed21db2

Browse files
committed
fix: add specific prototypes for casting to avoid warnings in modern compilers
1 parent 2374adc commit ed21db2

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/exp.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ typedef union unibin opfunc_t;
5050
#else /* warning: Calling functions without prototype */
5151

5252
typedef void (*opfunc_t)();
53+
54+
/* Add specific prototypes for casting to satisfy modern compilers */
55+
typedef void (*unop_func_t)(long, int);
56+
typedef void (*binop_func_t)(long, long, int, int);
57+
5358
#define _unary
5459
#define _binary
5560

@@ -642,7 +647,12 @@ void evaltop(void)
642647
return;
643648
}
644649
--Argi;
645-
(*Opdis[Opi]_unary)(Argstack[Argi], Argflags[Argi]);
650+
#if UNION
651+
(*Opdis[Opi].unary)(Argstack[Argi], Argflags[Argi]);
652+
#else
653+
/* Cast to specific prototype to avoid deprecated warning */
654+
((unop_func_t)Opdis[Opi])(Argstack[Argi], Argflags[Argi]);
655+
#endif
646656
}
647657
else
648658
{
@@ -654,8 +664,14 @@ void evaltop(void)
654664
}
655665

656666
Argi -= 2;
657-
(*Opdis[Opi]_binary)(Argstack[Argi], Argstack[Argi+1],
667+
#if UNION
668+
(*Opdis[Opi].binary)(Argstack[Argi], Argstack[Argi+1],
658669
Argflags[Argi], Argflags[Argi+1]);
670+
#else
671+
/* Cast to specific prototype to avoid deprecated warning */
672+
((binop_func_t)Opdis[Opi])(Argstack[Argi], Argstack[Argi+1],
673+
Argflags[Argi], Argflags[Argi+1]);
674+
#endif
659675
}
660676
}
661677

0 commit comments

Comments
 (0)