I have read all the questions I can find about this, but nobody has yet addressed my confusion.
If I understand correctly, the use of a double underscore at the beginning of a method or variable name in library code is simply a namespace convention. It allows the operating system code to avoid clashing with any application code.
Why, then, does my /usr/include/string.h contain, for example, the following function declaration;
extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)
__THROW __nonnull ((1, 2));
Ignoring the __THROW and __nonnull ((1, 2)); parts, I have the following questions;
Why do they use double-underscore for the local variable names
__destand__src, when surely these are only ever reachable by the implementation (presumably instring.cor similar), and can never clash with my code. (as an aside, I never really understood why forward declarations needed parameter names, shouldn't the types alone be enough?)Why is the function name not
__strcpy? Doesstring.hnot count as part of the operating system?Why are the words
constandrestrictaltered to use double-underscore? Aren't they already reserved words in the C99 (or earlier?) standard?
Clearly I've got my wires crossed somewhere along the line, if someone could clear this up for me that would be great.