Having never written a var_args program in my life, I can happily
say I have no idea, although I suspect the only portable
way to build a var_args list is to get the compiler to do it
for you (not useful in this case). However, I can suggest you abandon
the var_args approch and use a switch, eg:
switch (num_args) {
case 0:
(*f)();
break;
case 1:
(*f)(arg1);
break;
case 2:
(*f)(arg1, arg2);
break;
/* ... */
}
which will probably cause you much less grief.
> I'd preferably like a way to do it without having to consider
> each possible permutation of the typelist string, and I'd really
> like to be told it can be done in portable C... I could do it on
> a PC, with stack based passing using just a little hack - but t>
> hats not very portable - and I wouldn't have a clue how to do it
> so that it would work on ftoomsh anyway!
>
> btw... the actual use of this code is very good - this is a highly
> simplified example, but anyway :P
>
> I'd appreciate any help from all you clever ppl out there.... because
> I've spent a day on it and don't have a clue!
Give up! Don't do it! Pass arrays if you have to! Abandon all hope!
Does that help?
Cheers,
Christopher.