Hi,
In many codes and projects, I find variable names, structure definition, headerfile names starting with _ (underscore sign). Is that supposed to mean anything? Are they treated in some different manner?
Edesign
Printable View
Hi,
In many codes and projects, I find variable names, structure definition, headerfile names starting with _ (underscore sign). Is that supposed to mean anything? Are they treated in some different manner?
Edesign
I believe names with a '_' preceeding them are reserved for compiler/implementation specific names.
That means, unless you're building a compiler or something, you're technically not supposed to do that.
Variable names can start with an underscore. There's no problem with that. Heres a simple example.
Code:#include<stdio.h>
int main(void)
{
int _it;
scanf("%d",&_it);
printf("%d",_it);
}
In some cases. But it is not always true.
Compilers are known to accept incorrect coding constructs.
The C standard Section 7.1.3 "Reserved identifiers" has this to say on the subject.
(other categories of reserved identifiers not related to this topic not quoted).Quote:
Each header declares or defines all identifiers listed in its associated subclause, and optionally declares or defines identifiers listed in its associated future library directions subclause and identifiers which are always reserved either for any use or for use as file scope identifiers.
— All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use.
— All identifiers that begin with an underscore are always reserved for use as identifiers with file scope in both the ordinary and tag name spaces.