symbian 下 不定参数的函数

来源:互联网 发布:易语言ftp源码 编辑:程序博客网 时间:2024/04/19 07:22

e32def.h contains the va_list, va_start and va_end macros.

 

// Definition
int math (const OperatorType ty ...)
{
va_list ap; // param list
va_start(ap,ty); // where to start in the list i.e. after ty
int x = va_arg(ap,int); // go through the parameters, which are ints
int res = 0;
while (0!=x) // while not zero
{
switch (ty)
{
case ADD: // other cases, e.g. SUBTRACT, not used
default:
res+=x;
}
x = va_arg(ap,int); // Get next param
}
va_end(ap); // clean up the stack frame
return res;
}
// Called
int r = math(ADD,1,2,3,4,5);