FiSer
FiSer

Reputation: 27

Maximum length of lines

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.

Upvotes: 1

Views: 1769

Answers (1)

KamilCuk
KamilCuk

Reputation: 140880

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.

Upvotes: 2

Related Questions