Now I am designing a function f(index,...)
which will call #index entry in a function array passing the rest of parameters. If you see the function array as a service list, f
acts like a service distributer.
f
is written in assembly. It pops the first parameter index
then calculates the corresponding target function address and jmp to it.
If I pass n
parameters to f
, the stack just holds n-1
ones when returning from the target function, because index
was popped midway. For this reason, I cannot use cdecl
convention, or the caller will clean the stack for n
parameters by mistake.
stdcall
should works. But the problem is that, since f
has variable arguments, gcc seems __attribute__((stdcall)) f(index,...)
unreasonable and reverts it back to cdecl
.
So please could any one tell me how to declare f
to be stdcall
?