Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
623 views
in Technique[技术] by (71.8m points)

gcc - Maximum length of statement in C

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

compiler is gcc

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...