•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 427,191 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 2,228 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: 447 | Replies: 3
![]() |
>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.
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 11:47 am.
"No man's life, liberty, or property is safe while the legislature is in session." ~ Mark Twain
To elaborate:
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().
•
•
•
•
>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.
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
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
![]() |
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- def function(): help (Python)
- QBASIC under Windows XP (Visual Basic 4 / 5 / 6)
- Is there a way(function) to distingusih between different data types? (C++)
- Anyone have a good programes..? PlZ (C)
- Passing 2D Array of Pointers into a function (C++)
- Callback function (C++)
- Function that creates random changes in a string?? (Python)
- DNS record types (PHP)
Other Threads in the C Forum
- Previous Thread: problems with a code made in linux working in windows
- Next Thread: giving gdb debugger argument



Linear Mode