User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 456,567 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,595 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 478 | Replies: 3
Reply
Join Date: Oct 2007
Posts: 9
Reputation: Justmehere is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Justmehere Justmehere is offline Offline
Newbie Poster

__XXXXXX Function Types

  #1  
Oct 20th, 2007
Can anyone tell me what the purpose of C functions which start with "__" ? Also another question is the same use of the "__" in defines like #define __HTTP_VERB_GET "GET"
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2006
Posts: 1,569
Reputation: Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold 
Rep Power: 12
Solved Threads: 114
Aia's Avatar
Aia Aia is offline Offline
Posting Virtuoso

Re: __XXXXXX Function Types

  #2  
Oct 20th, 2007
>Can anyone tell me what the purpose of C functions which start with "__" ?

It's customary for compiler to name their functions and macros starting with some "_" or "__" in order to make it harder for an user define function to conflict in naming.
It's recomended that you don't use those character to name your own created functions.

>Also another question is the same use of the "__" in defines like #define __HTTP_VERB_GET "GET"

The precompiler will sustitute GET every time that it will see it, for __HTTP_VERB_GET; which will be declared somewhere in a header file.
Last edited by Aia : Oct 20th, 2007 at 12:47 pm.
At the very moment that I find myself in the side of the mayority, I will know that I need to re-think my ideas. ~ In my book.
Reply With Quote  
Join Date: Oct 2007
Posts: 9
Reputation: Justmehere is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Justmehere Justmehere is offline Offline
Newbie Poster

Re: __XXXXXX Function Types

  #3  
Oct 20th, 2007
Thanks Aia.
Reply With Quote  
Join Date: Nov 2005
Location: Canada
Posts: 236
Reputation: dwks will become famous soon enough dwks will become famous soon enough 
Rep Power: 4
Solved Threads: 21
dwks's Avatar
dwks dwks is offline Offline
Posting Whiz in Training

Re: __XXXXXX Function Types

  #4  
Oct 20th, 2007
To elaborate:
>Can anyone tell me what the purpose of C functions which start with "__" ?

It's customary for compiler to name their functions and macros starting with some "_" or "__" in order to make it harder for an user define function to conflict in naming.
It's recomended that you don't use those character to name your own created functions.
As a matter of fact, identifiers that begin with an underscore followed by another underscore or an uppercase letter are reserved for the implementation, that is, for the compiler. You shouldn't use names like these at all, on the off chance that some compiler has also used the very same name.

There are no such restrictions on these characters in the middle of identifiers. an__identifier and my_Name are perfectly acceptable.

It should be noted that functions and types and identifiers declared with double underscores or _X are likely specific to the compiler. This means that if your code uses these functions it likely won't be very portable. There are exceptions, of course. mkdir() is a very common UNIX function, and MSVC declares it as _mkdir().
dwk

Seek and ye shall find.

"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.

"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison

"The only real mistake is the one from which we learn nothing."
-- John Powell
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 5:55 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC