In article <11*********************@m79g2000cwm.googlegroups. com>
cybernerdsx2 <fo*********@gmail.comwrote:
>I notice a function prototype being declared as following:
FileStream.h
=========
extern void openFile(char *__ident, int __option);
But, in the function declaration part shown as following:
FileStream.c
=========
void openFile(char *ident, int option)
{
...
}
Why is that the "__" prefix for "ident" and "option" required?
They are not only not required, they are also a *bad* idea, with
one exception.
As far as the C standards are concerned, there are only two kinds
of programmers in the world: ones like me, who write the compilers
for you -- we are called "implementors" -- and ones like you, who
use the compilers we write.
Suppose I, as an implementor, am working on the file that I will
provide as <string.h>. In this file, I write:
char *strcpy(char *restrict dst, const char *restrict src);
Now you, as the user of my <string.h>, do this:
/* this is my module that does some funny stuff with times */
#define dst 1 /* compile in support for Daylight Saving Time */
#include <string.h/* I need some functions from here */
You defined "dst" as 1, and then you included my (implementor's)
<string.h>, which -- in my implementation at least -- is just an
ordinary file with ordinary C rules applied. So the line I wrote
now reads, to the compiler, as:
char *strcpy(char *restrict 1, const char *restrict src);
and you get a "syntax error".
This is my fault: as an implementor, I *must* allow you to "#define
dst" however you like. So I *cannot* use that name.
If I want to use names in my <string.hprototypes, what can I do?
The answer is: I can use names that, according to the C standands,
*you* must *not* use. Those names include any names that start
with double underscore, or underscore followed by an uppercase
letter. So *I* can use:
char *strcpy(char *restrict __dst, const char *restrict _SRC);
and thus be sure that I did not use any of "your" names. These
names are "my" names: names reserved to me.
If you use any of my names, the problem is yours, not mine. You
stick to your names, and I stick to mine, and everything will be
just fine.
(The other alternative here is that I can just write the prototypes
with no names at all. But at some point, I have to write various
internal functions, e.g., to implement parts of fopen(), fclose(),
fflush(), and so on; I will need names for those functions, and I
will need to make sure that my names do not conflict with your names.)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it
http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.