I'm working on rewriting a C program in C++ to take advantage of OO aspects so it can easily support multiple devices, and one part of the program is an expression evaluator. Expressions can have function calls, and here's the structure for functions.
typedef struct {
char *name;
int argc;
void (*func) ();
} FUNCTION;
Somehow func can have a variable number of arguments passed through it.
RESULT *param[10];
if (Root->Function->argc < 0) {
/* Function with variable argument list: */
/* pass number of arguments as first parameter */
Root->Function->func(Root->Result, argc, ¶m);
} else {
Root->Function->func(Root->Result, param[0], param[1], param[2], param[3], param[4], param[5], param[6],
param[7], param[8], param[9]);
}
I'm not even sure how this can be done in C to be honest. An explanation would be excellent. Can it be done in C++?