C中语句的最大长度 [英] Maximum length of statement in C

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

问题描述

在C中定义的语句是否有最大长度?



编译器是gcc

解决方案


c11

5.2.4.1翻译范围



1执行应能够翻译和执行至少一个程序,
至少包含以下每一个限制的一个实例:

[...]



- 逻辑源代码行中的4095个字符


标准建议实现应该尽量避免强加固定的翻译限制。



逻辑源代码行是反斜线 - 换行拼接的结果(5.1。 1.2:1.2),所以这不会直接覆盖语句中字符数的最小限制。



Howeve r,因为另一个转换限制要求是:

lockquote

- 字符串文字中4095个字符(连接后)

以及字符串文字只能出现在语句中,因此实现必须接受至少一个4095字符的语句。



忽略文字,我们也看到:

lockquote

- 在一个函数调用中有127个参数

,并且作为函数调用,每个参数必须包含至少2个字符,并加上4个调用( f(0,0,...) ; ),我们的最小线长度限制为260美元。


Is there a maximum length for a statement defined in C?

compiler is gcc

解决方案

The standard specifies a minimum translation limit:

5.2.4.1 Translation limits

1 The implementation shall be able to translate and execute at least one program that contains at least one instance of every one of the following limits:

[...]

— 4095 characters in a logical source line

The standard recommends however that "implementations should avoid imposing fixed translation limits whenever possible".

A logical source line is the result of backslash-newline splicing (5.1.1.2:1.2), so this doesn't directly cover the minimum limit for the number of characters in a statement.

However, because another translation limit requirement is:

— 4095 characters in a string literal (after concatenation)

and as string literals may only occur in statements, it follows that the implementation must accept at least one 4095-character statement.

Ignoring literals, we also see:

— 127 arguments in one function call

and as a function call must include at least 2 characters per argument, plus 4 for the invocation (f(0,0,...);) we arrive at a minimum line length limit of 260.

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

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