在函数声明参数的最大数目 [英] Maximum number of parameters in function declaration

查看:112
本文介绍了在函数声明参数的最大数目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,在函数定义的参数的最小数目是零,但什么是在函数定义的参数的最大值是多少?我问这个问题只是知识的缘故,并出于好奇,不是说我会写一个真实的功能。


解决方案

是的,有被执行强加的限制。你的答案是在从C ++标准以下摘录了大胆的文字说明。

1。 C ++语言


附录B - 实施数量


  

      
  1. 由于电脑是有限的,C ++实现都不可避免地限制
      在他们可以在程序的大小
      成功处理。
      实现应记录这些
      其中,已知限制。
    :此
      文档可能引用固定限制
      如果有的话,说怎么计算
      可变限量的函数
      可利用的资源,或者说固定
      限制不存在或未知。


  2.   
  3. 该限制可能数量,包括低于或描述的那些
      其他。 方括号内的数字如下
      每个量推荐为
      最低的数量。
    然而,
      这些数量仅仅是指导
      不要判断是否符合。
    -
      复合语句的嵌套层次,
      迭代控制结构,和
      选择控制结构[256]
    -
      有条件的嵌套级别
      夹杂物[256]。
    - 指针,数组,
      函数声明(在任何
      组合)修改算术,
      结构,联合或不完全类型
      在声明中[256]。
    - 嵌套
      括号内的前pressions水平
      在一个完整的前pression [256]。
    -
      字符中的内部编号
      标识符或宏名[1 024]。
    -
      字符在外部号码
      标识符[1 024]。
    - 外部
      在一个翻译单元标识符
      [65 536]。
    - 标识符与块
      范围在一个块[1024]声明。
    -
      同时宏标识符
      在一个转换单元中定义[65
      536]。
    - 在一个函数中的参数
      定义[256]。
    - 参数在一个
      函数调用[256]

    - 在参数
      一个宏定义[256]。
    -
      在一个宏调用的参数
      [256]。
    - 人物在一个逻辑
      源代码行[65536]。
    - 字符在
      字符串文字或宽
      字符串(串联之后)
      [65 536]。
    - 对象的尺寸[262
      144]。
    - 嵌套层次对于#include
      文件[256]。
    - case标签的
      switch语句(不包括对
      任何嵌套switch语句)[16
      384]。
    - 数据成员在一个单一的
      类,结构或联合[16 384]
    -
      在一个单一的枚举常量
      枚举[4096]。
    - 水平
      嵌套类,结构或联合
      在一个单一的定义
      结构声明列表[256]。
    -
      由atexit对注册功能()[32]。
      
    - 直接和间接基类[16
      384]。
    - 对于直接基类
      单班[1024]。
    - 会员
      在一个类中[4096]宣布
    -
      在最终压倒一切的虚函数
      一类,访问或不[16 384]。
    -
      直接和间接虚拟基
      类[1 024]。
    - 的静态成员
      类[1 024]。
    - 朋友的声明
      一类[4096]。
    - 访问控制
      在类的声明[4096]。
    -
      在构造函数初始化成员
      定义[6 144]。
    - 范围
      一个标识符的资格
      [256]。
    - 嵌套外部
      规格[1 024]。
    - 模板
      论点模板声明[1
      024]。
    - 递归嵌套模板
      实例[17]。
    - 每处理程序
      try块[256]。
    - 投掷
      单一功能规范
      声明[256]。


  4.   

除了

,它也说,在$ 18.3 / 6,


  

实现限制:
  实施应​​支持
  至少有32函数注册。


I know that minimum number of parameters in function definition is zero, but what is the maximum number of parameters in function definition? I am asking the question just for the sake of knowledge and out of curiosity, not that I am going to write a real function.

解决方案

Yes, there are limits imposed by the implementation. Your answer is given in the bold text in the following excerpt from the C++ Standard.

1. C++ Language


Annex B - Implementation quantities

  1. Because computers are finite, C + + implementations are inevitably limited in the size of the programs they can successfully process. Every implementation shall document those limitations where known. This documentation may cite fixed limits where they exist, say how to compute variable limits as a function of available resources, or say that fixed limits do not exist or are unknown.

  2. The limits may constrain quantities that include those described below or others. The bracketed number following each quantity is recommended as the minimum for that quantity. However, these quantities are only guidelines and do not determine compliance.
    — Nesting levels of compound statements, iteration control structures, and selection control structures [256].
    — Nesting levels of conditional inclusion [256].
    — Pointer, array, and function declarators (in any combination) modifying an arithmetic, structure, union, or incomplete type in a declaration [256].
    — Nesting levels of parenthesized expressions within a full expression [256].
    — Number of characters in an internal identifier or macro name [1 024].
    — Number of characters in an external identifier [1 024].
    — External identifiers in one translation unit [65 536].
    — Identifiers with block scope declared in one block [1 024].
    — Macro identifiers simultaneously defined in one translation unit [65 536].
    — Parameters in one function definition [256].
    — Arguments in one function call [256].

    — Parameters in one macro definition [256].
    — Arguments in one macro invocation [256].
    — Characters in one logical source line [65 536].
    — Characters in a character string literal or wide string literal (after concatenation) [65 536].
    — Size of an object [262 144].
    — Nesting levels for #include files [256].
    — Case labels for a switch statement (excluding those for any nested switch statements) [16 384].
    — Data members in a single class, structure, or union [16 384].
    — Enumeration constants in a single enumeration [4 096].
    — Levels of nested class, structure, or union definitions in a single struct-declaration-list [256].
    — Functions registered by atexit()[32].
    — Direct and indirect base classes [16 384].
    — Direct base classes for a single class [1024].
    — Members declared in a single class [4 096].
    — Final overriding virtual functions in a class, accessible or not [16 384].
    — Direct and indirect virtual bases of a class [1 024].
    — Static members of a class [1 024].
    — Friend declarations in a class [4 096].
    — Access control declarations in a class [4 096].
    — Member initializers in a constructor definition [6 144].
    — Scope qualifications of one identifier [256].
    — Nested external specifications [1 024].
    — Template arguments in a template declaration [1 024].
    — Recursively nested template instantiations [17].
    — Handlers per try block [256].
    — Throw specifications on a single function declaration [256].

Besides, it also says in $18.3/6,

Implementation Limits: The implementation shall support the registration of at least 32 functions.

这篇关于在函数声明参数的最大数目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆