Calls with a Variable Number of Arguments

原创 2004年08月18日 16:45:00

From: C Language Reference (Visual C++ .NET)

A partial parameter list can be terminated by the ellipsis notation, a comma followed by three periods (, ...), to indicate that there may be more arguments passed to the function, but no more information is given about them. Type checking is not performed on such arguments. At least one parameter must precede the ellipsis notation and the ellipsis notation must be the last token in the parameter list. Without the ellipsis notation, the behavior of a function is undefined if it receives parameters in addition to those declared in the parameter list.

To call a function with a variable number of arguments, simply specify any number of arguments in the function call. An example is the printf function from the C run-time library. The function call must include one argument for each type name declared in the parameter list or the list of argument types.

All the arguments specified in the function call are placed on the stack unless the __fastcall calling convention is specified. The number of parameters declared for the function determines how many of the arguments are taken from the stack and assigned to the parameters. You are responsible for retrieving any additional arguments from the stack and for determining how many arguments are present. The STDARG.H file contains ANSI-style macros for accessing arguments of functions which take a variable number of arguments. Also, the XENIX?- style macros in VARARGS.H are still supported.

This sample declaration is for a function that calls a variable number of arguments:

int average( int first, ...);
Microsoft Specific —>

To maintain compatibility with previous versions of Microsoft C, a Microsoft extension to the ANSI C standard allows a comma without trailing periods (,) at the end of the list of parameters to indicate a variable number of arguments. However, it is recommended that code be changed to incorporate the ellipsis notation.

END Microsoft Specific

Lua 5.1 参考手册 + Lua程序设计

1 - 介绍 Lua 是一个扩展式程序设计语言,它被设计成支持通用的过程式编程,并有相关数据描述的设施。 Lua 也能对面向对象编程,函数式编程,数据驱动式编程提供很好的支持。 它可以作为一个强大、...
  • sssssNian
  • sssssNian
  • 2014-10-22 11:56:13
  • 732

CMake help

cmake version 2.8.4 ------------------------------------------------------------------------------ ...
  • a174787252
  • a174787252
  • 2014-12-09 10:38:47
  • 1937

execl 编译时的警告: warning: not enough variable arguments to fit a sentinel 解释说明(转载)

GCC 4 warnings about sentinelsIntroductionWhen compiling something with GCC 4, it may be possible th...
  • lllxy
  • lllxy
  • 2007-12-24 16:02:00
  • 4087

拟合数据时报错Number of calls to function has reached maxfev = 1000

在用Scipy拟合曲线时,调用curve_fit 或leastsq 可能会出现 RuntimeWarning:Number of calls to function has reached maxf...
  • xrazor
  • xrazor
  • 2017-09-11 15:16:49
  • 517

Lua - 调试接口

 Lua - 调试接口4 - 调试接口 The Debug InterfaceLua 没有内置的调试设施。它使用一种特殊的接口,这种接口依赖函数和 钩子(hooks)。该接口允许构造不同种类的调试器,...
  • skyremember
  • skyremember
  • 2008-10-25 02:00:00
  • 11583

cocos完整版改动列表

cocos2d-x-3.13 Aug 22 2016       [HIGHLIGHT] add VR plugin   [HIGHLIGHT] sup...
  • Anzhongliu
  • Anzhongliu
  • 2016-08-31 14:42:43
  • 2045

redis操作实战

1.hash 127.0.0.1:6379> keys *ServiceConfig* 1) "NGMA_SYSTEM:com.polycom.rpum.core.dal.memi.NgmaServi...
  • hanruikai
  • hanruikai
  • 2015-06-11 17:10:01
  • 950

Redis Hash操作

redis 127.0.0.1:6379> hset user user2 9000 (integer) 1 redis 127.0.0.1:6379> hset uset user3 8000 ...
  • luyee2010
  • luyee2010
  • 2013-05-29 14:43:42
  • 6008

c# asp.net ajax 用法一例

 c# asp.net ajax 用法一例        //Ajax Asp.net 2.0方法                //---------------eg2 begin        f...
  • hsg77
  • hsg77
  • 2011-06-09 16:36:00
  • 689

点击文字显示,点击文字隐藏

点击文字隐藏,点击文字显示。使用于文字列表。
  • qq_38881495
  • qq_38881495
  • 2018-01-04 14:50:57
  • 185
收藏助手
不良信息举报
您举报文章:Calls with a Variable Number of Arguments
举报原因:
原因补充:

(最多只允许输入30个字)