I am wondering if there is a limit for the length of a line (Characters per line) in a code written in C, something similar to the Fortran 72 (or 80 including all) limit. I know that style guides usually point towards 80 for readability purposes but I want to know if there is a real limit for C as it does happens for Fortran.
Asked
Active
Viewed 897 times
1
-
2Does this answer your question? [Source line length limit](https://stackoverflow.com/questions/10519738/source-line-length-limit) – IndieGameDev Oct 06 '20 at 10:28
-
fwiw limit in Fortran is 132: https://stackoverflow.com/questions/44990119/why-is-maximum-single-line-length-limited-to-132-characters-in-fortran-standard – 463035818_is_not_an_ai Oct 06 '20 at 10:28
-
1C and C++ are two seperate languages with their own set of rules. Please dont tag both unless the question is about interoperation of the two languages. – 463035818_is_not_an_ai Oct 06 '20 at 10:30
-
@MathewHD It does answer it for C++, so I changed the question to only include C – klutt Oct 06 '20 at 10:30
1 Answers
2
From C11 5.2.4.1 Translation Limits:
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
Any C compiler should be able to process at least lines with 4095 characters. Nowadays compilers have no upper limit - it is effectively constrained by available memory.
As an example gcc documentation Implementation Limits states:
- Number of characters on a logical source line.
The C standard requires a minimum of 4096 be permitted. CPP places no limits on this, but you may get incorrect column numbers reported in diagnostics for lines longer than 65,535 characters.

KamilCuk
- 120,984
- 8
- 59
- 111