可变长度 [英] Variable Length

查看:79
本文介绍了可变长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道c中的变量长度是多少。

我K& R他们说至少31个字符。

但我给了一个十万卢比的长度变量,但我的编译器没有说

任何错误。

接受它。那么变量名的最大长度是多少。?

I want to know what is the variable length in c.
I K&R they stated that atleast 31 character.
But I give 1 lakhs length to a variable, but my compiler doesn''t say
any error.
It accepts it.Then what is the maximum length to a variable name.?

推荐答案

lak写道:
lak wrote:

我想知道c中的变量长度是多少。

我K& R他们说至少31个字符。

但是我给变量一个十万分之一长,但我的编译器并没有说

任何错误。

它接受它。然后变量名的最大长度是多少。?
I want to know what is the variable length in c.
I K&R they stated that atleast 31 character.
But I give 1 lakhs length to a variable, but my compiler doesn''t say
any error.
It accepts it.Then what is the maximum length to a variable name.?



限制是关于标识符,而不仅仅是变量名称;函数名称,例如
也是标识符。


31个字符的限制仅适用于外部标识符。内部

标识符的限制为63(5.2.4p1)。


该限制是最小值,而不是最大值。 对于标识符的最大长度,

没有特定限制。 (6.4.1p2)。


最低限制是对实现者的要求,而不是

开发人员的要求。这意味着如果两个外部标识符的前32个字符不同,则需要实现将它们识别为

不同。如果第一个差异出现在第31个
字符之后,则允许实现(但不是必需)将

两个标识符视为相同,这通常会导致问题

在编译期间的某处,除非它只是一个错字,在这种情况下

它会引起代码读者的混淆。


一个好的编译器应该警告你,如果你有两个外部标识符

只有在第31个字符之后才有区别。一个挑剔的编译器可能会警告你甚至使用超过31个字符的标识符。这是一个有用的警告,因为人类读者很容易被误导思考

整个标识符是有意义的,而不仅仅是第一个31

个字符。

The limit is on identifiers, not just variable names; function names,
for instance, are also identifiers.

The 31 character limit is only on external identifiers. Internal
identifiers have a limit of 63 (5.2.4p1).

That limit is a minimum, not a maximum. "There is no specific limit on
the maximum length of an identifier." (6.4.1p2).

The minimum limit is a requirement on the implementor, not on the
developer. It means that if two external identifiers differ in their
first 31 characters, an implementation is required to recognize them as
being different. If the first difference occurs after the 31st
character, an implementation is allowed, but not required, to treat the
two identifiers as being the same, which usually causes problems
somewhere during compilation, unless it was only a typo, in which case
it can cause confusion in readers of the code.

A good compiler should warn you if you have two external identifiers
that differ only after the 31st character. A picky compiler might warn
you about even using identifiers longer than 31 characters. That''s a
useful warning, because human readers can be easily misled into thinking
the whole identifier is meaningful, rather than just the first 31
characters.


lak写道:
lak wrote:

我想知道c中的变量长度是多少。

我K& R他们说至少31个字符。

但我给变量一个十万分之一长,但我的编译器并没有说

任何错误。

它接受它。那么变量名的最大长度是多少。?
I want to know what is the variable length in c.
I K&R they stated that atleast 31 character.
But I give 1 lakhs length to a variable, but my compiler doesn''t say
any error.
It accepts it.Then what is the maximum length to a variable name.?



最低限额在C标准中给出。实施可以

进一步放宽这些限制。


PS。一个十万字符的标识符就是疯狂的b / b
mad。您有没有理由进行无意义的锻炼?

The minimum limits are given in the C Standard. Implementations may
relax these restrictions further as appropriate.

PS. An identifier of hundred thousand characters is nothing short of
mad. Was there a reason for your pointless exercise?


James Kuyper写道:


[...]
James Kuyper wrote:

[...]

限制是标识符,而不仅仅是变量名称;函数名称,例如
也是标识符。


31个字符的限制仅适用于外部标识符。内部

标识符的限制为63(5.2.4p1)。
The limit is on identifiers, not just variable names; function names,
for instance, are also identifiers.

The 31 character limit is only on external identifiers. Internal
identifiers have a limit of 63 (5.2.4p1).



我很确定在C99之前限制要少得多。


我无法访问C89 std。在这里,但如果记忆对我有用,

最少8个初始字符是显着的(外部标识符)。

-

Tor< torust [at] online [dot] no>

I''m rather sure that limit was far less before C99.

I don''t have access to C89 std. here, but if memory serves me right,
minimum of 8 initial characters was significant (external identifiers).
--
Tor <torust [at] online [dot] no>


这篇关于可变长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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