Hacker News new | ask | show | jobs
by samatman 2116 days ago
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.

1 comments

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.