`
javayestome
  • 浏览: 1017176 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

symbian 下 不定参数的函数

阅读更多

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);

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics