I've seen a lot of the minimal requirements that an ANSI C compiler must support like 31 arguments to a function, and most of the numbers seem to make some kind of sense.
However, I cannot see the reasoning for supporting at least 509 characters in a source line. 511 or 512 would make more sense, but 509 seems kind of arbitrary.
What is the reason for this number?
This perhaps is to take account of possible CR
+ LF
+ '\0'
characters and have a string representation of each line still fit into 512 bytes of memory.
The C11 dr 5.2.4.1 limits are different than given by the OP. I suspect they come from C89.
4095 characters in a logical source line
4095 characters in a string literal (after concatenation)
[Edit] @jwodder suggested a more complete answer was needed.
Best I can provide: 512 bytes was the most common sector size for floppy, diskette and hard drive media circa mid 80 to mid 90s and likely contributed, along with @bizzehdee & @DigitalTrauma thoughts as to the curious 509 limit.
It was a very popular buffer size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With