4 ms·
Limits can work, but IIRC the original C would have set the limit on meaningful length of a variable name at 8 (or was it 6?). That... turned out to be a bad p
by AnimalMuppet 5y ago
Limits can work, but IIRC the original C would have set the limit on meaningful length of a variable name at 8 (or was it 6?). That... turned out to be a bad place to set that limit. So the limit had to be changed. But the more support the tooling gives for "preserving portability", the more support it gives for making it hard to change the limit when it needs to be changed.
- kazinator 5y agoThe 6 limit was due to ancient linkers on Unix, which truncated external names to 6 characters. This affected file-scope identifiers with linkage (external or internal). If a compiler has to work with some object file format which allows only six character symbol names (with case being indistict), there is nothing that can be done; but there is little reason to impose such a stringent limit if the underlying linker technology has a much more lenient one. I think C90 still made that 6 character the minimum limit; a conforming C implementation of C90 was not required to accept a program which makes two external definitions that do not differ in the first six characters of the name, ignoring case. In those days, it would have been useful to have a warning if you're using longer identifiers, or if your identifiers are not unique in the first N characters. C99 raised a bunch of these limits, including that one; it became 31 characters. No mention is made that case is indistinct; it must be distinct. The limit is still there; use 32 and your program is not strictly conforming to C99.