本地范围内可以有多少个变量
How many variables can be in local scope
我的问题很简单:局部范围内有多少变量可以被正确翻译?
我必须创建一个从 C++ 到汇编的小型转换器(用于学习目的)。在翻译过程中,有一个动态的 table 标识符(变量名称,在简单的情况下,我想)。能有多少个?
我的意思是,我的 table 也是动态的,但我需要创建一个令牌数组,其中每个令牌都有 2 个数字 - table ID 和 [= 中的记录 ID 19=]。所以我想知道,这些 ID 应该是哪种类型 - int
、short
、long
等?
How many variables can be in local scope
C++ 标准没有指定确切的最大数量。
它确实有以下建议(引用自最新标准草案):
[implimits]
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.
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.
- Identifiers with block scope declared in one block ([basic.scope.block]) [1'024].
有人为此写了一个测试,常用的编译器似乎至少支持 8k:https://github.com/fritzone/cpp-stresstest
我的问题很简单:局部范围内有多少变量可以被正确翻译?
我必须创建一个从 C++ 到汇编的小型转换器(用于学习目的)。在翻译过程中,有一个动态的 table 标识符(变量名称,在简单的情况下,我想)。能有多少个?
我的意思是,我的 table 也是动态的,但我需要创建一个令牌数组,其中每个令牌都有 2 个数字 - table ID 和 [= 中的记录 ID 19=]。所以我想知道,这些 ID 应该是哪种类型 - int
、short
、long
等?
How many variables can be in local scope
C++ 标准没有指定确切的最大数量。
它确实有以下建议(引用自最新标准草案):
[implimits]
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.
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.
- Identifiers with block scope declared in one block ([basic.scope.block]) [1'024].
有人为此写了一个测试,常用的编译器似乎至少支持 8k:https://github.com/fritzone/cpp-stresstest