Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
617 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...