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

I wasn't aware of that last point. Is this the answer why we have uniquely prefixed struct members in POSIX? Such as st_* in struct stat or d_* in struct dirent? Is that just a coincidence?



Another thing that it allows you is to #define "structure member" to be something more complex, for example on Linux you get st_atime (as in struct stat) #defined to st_atim.tv_sec (and so on for ctime, mtime, st_a/c/mtim is struct timespec, with nanosecond precision).


Yes, that's why member functions tend to have unique prefixes.


I don't think so. I'm going from memory here, but I think in pre-K&R C it wasn't assumed that every struct/union would be given its own separate namespace.


That also makes grepping for all occurrences of "flags" more useful, when it's p_flags or d_flags.




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

Search: