Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

__XYZ__ what it means?

Status
Not open for further replies.

gaurava

Programmer
Jun 12, 2002
1
US
Hi!,
Can you tell me what is the significance of using "_" or "__" while declaring any function or #define?
I see a lot of #define or typedef structs with these things.
eg:
typedef struct xyz {
....
....
} __ABC__ efg.
or,
_func(); // in declarations usually,but when called,the "_" is dropped.

Regards,
Kumar Gaurava.
 
Hi,

Nothing too special with it. All they are really there for (as far as I have heard) is to make sure that there are no naming conflicts in case the definitions or functions are already defined in some header file you are including. So, suppose you put a define like

#ifndef STANDARD
#define STANDARD
....
#endif

And you include somebody elses header file and they had

#ifndef STANDARD
#define STANDARD
...
#endif

Well, you can see there will be a problem since it will define STANDARD on the first one it saw and never hit your other code. By using

#ifndef __STANDARD__
#define __STANDARD__
...
#endif

You make it less likely that someone else has already defined it somewhere else.

-Tyler
-Tyler
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top