On Wed, 17 Aug 2005 11:38:51 +0900, "Roman Mashak" <mr*@tusur.ru >
wrote in comp.lang.c:
Hello, All!
I often meet that '_' or '__' is used as prefix to
functions/macros/variables names. I wonder does it have some strict meaning?
I didn't find any distinct explanation in C standard or local FAQ.
All symbols beginning with two underscores ("__") or one underscore
followed by a upper case letter ("_A" through "_Z"), are reserved for
the implementation (compiler, its headers and library) in all
contexts.
All symbols beginning with an underscore followed by a lower case
letter ("_a" through "_z") are also reserved for the implementation at
file scope.
If you look at a header supplied by your compiler, you might see that
it includes something like this at the top:
#ifndef __STDIO_H__
#define __STDIO_H__
/* contents of header */
#endif
The point is that the standard reserves some identifiers for the
implementation so that it can define its own macros, data types,
internal helper functions, and non-standard extensions that will not
clash with any identifiers a programmer uses, if the programmer
understands and follows the rules.
Unfortunately, the vast majority of C (and C++) programmers do not
understand the rules. Most of them still define include guard macros
in their header files like this:
my_header.h:
#ifndef __MY_HEADER_H__
#define __MY_HEADER_H__
/* ... */
#endif
Because they see it in compiler supplied headers and somehow think it
is the thing to use in headers.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html