Hacker News new | past | comments | ask | show | jobs | submit login

This is not true. It requires compilers to support at least 31 significant initial characters in external names, 63 otherwise (in C99), but beyond that it is a quality of implementation issue and implementations are explicitly encouraged directly from that same standard not to impose artificial limits. The C standard allows and recommends compilers treat the full names of variables, functions and anything else as significant.



Ah, good to know, I thought it was proscriptive.

Let me rephrase, then: to write portable C, you must keep the first 31 characters of any name distinct, because it's legal for a compiler to ignore everything after that.


Yup, phrased like that it's about right and a legitimate gripe. The limits in C90 were even worse. There are still a few projects around that use the requirement to treat more characters as significant in internal names to work around that, like so:

  #define copy_from_memory copy1
  #define copy_from_file copy2
And then provide the declarations and definitions of copy_from_memory and copy_from_file as normal, knowing that they will be renamed to copy1 and copy2 by the preprocessor.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: