double underscore preceding variables

Status
Not open for further replies.

electroRF

Member
Hi,

I see in different sources / headers variables that are preceded by '__' (double underscore).

I read about it the following (attached quote).

What does it mean reserved to the implementation?

What implementation and whose?

additionally please, How should the programmer treat these variables? does one use these variables?

Thank you very much.


 
The document that you're reading is written for people who're implementing the standard, that is writing a C compiler. They're called implementors.
 
I always assumed, I think I'm right, that libraries written for C compilers, all the functions have an underscore when they are written in C and double when they are written in assembly.... As NorthGuy said its for those implementing the code...

I am referring to precompiled libraries... I should imagine it gets complicated when you call a routine that calls a routine of a similar name.... Some convention has got to be used...
 
The compiler/linker uses them and you don't.

Just suppose there were a few words:
__START
__CODE
__DATA
__ROUTINE1
__ROUTINE2

These might be necessary for the Compiler and linker to function. You don't want any C programmer messing with these. So anything beginning with a double underline is OFF LIMITS, i.e. reserved
 
I believe that the main motivation to use leading underscores is to avoid naming conflicts with the user program. It is unlikely that you will write any functions beginning with underscores.. at least you should not do that.
Practically the double underscore has the same purpose as namespaces in C++.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…