What is the purpose of prefixing struct member names like this?
What is the point of the "sa_" ?Code:struct sockaddr { unsigned short sa_family; char sa_data[14]; };
What is the purpose of prefixing struct member names like this?
What is the point of the "sa_" ?Code:struct sockaddr { unsigned short sa_family; char sa_data[14]; };
A reminder to the programmer - sa == sock address, pehaps?
What is the point of the "sa_" ?
I believe that in in K&R C [or some early implementations of C] struct types share the same "namespace", so in this old C standard, each struct member HAS to have a unique name - using a two-letter combination from the struct name itself helps making the names unique.
This is completely obsolete these days, but for compatibility with really old compilers, it's still used in some places [plus of course if you change it now, you'd break all the old code that was written using the old style names - although some clever tricks with #defines may be able to "fix" that].
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
A legacy from an ancient communal struct member namespace.
That sounds sad but true.
I thought it might have had something to do with debugging,
that the member names are visible at some point where
the struct type name (or the actual variable name) is not.
But I haven't used debuggers very often.