473,772 Members | 2,552 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

_ and __ significance

I have seen many variables or structures declared as _ or __ prefixed .
Can anyone explain the significance of _ or __ particularly . I mean ,
I wanted to know the convention for using _ and __ .

Sep 25 '06 #1
18 11188

g.*******@gmail .com wrote:
I have seen many variables or structures declared as _ or __ prefixed .
Can anyone explain the significance of _ or __ particularly . I mean ,
I wanted to know the convention for using _ and __ .
There is no particulat meaning in using _ or __ except that of a
general convention used to identify system variables/functions by
single underscore and metadata identified by double underscored.

-kondal

Sep 25 '06 #2

kondal wrote:
g.*******@gmail .com wrote:
I have seen many variables or structures declared as _ or __ prefixed .
Can anyone explain the significance of _ or __ particularly . I mean ,
I wanted to know the convention for using _ and __ .

There is no particulat meaning in using _ or __ except that of a
general convention used to identify system variables/functions by
single underscore and metadata identified by double underscored.

-kondal
Thanks for your reply. But ould you please explain metadata in a bit
detail.

Ankush

Sep 25 '06 #3
g.*******@gmail .com wrote:
I have seen many variables or structures declared as _ or __ prefixed .
Can anyone explain the significance of _ or __ particularly . I mean ,
I wanted to know the convention for using _ and __ .
Someone else will probably quote the exact legalese, but in general,
you shouldn't use names that begin with underscores because these names
can be reserved for various uses by your compiler/implementation.
Underscores inside names are often used to make identifiers more
readable - e.g. NUM_ITEMS instead of NUMITEMS.

Regards,
Bart.

Sep 25 '06 #4
g.*******@gmail .com wrote:
I have seen many variables or structures declared as _ or __ prefixed .
Can anyone explain the significance of _ or __ particularly . I mean ,
I wanted to know the convention for using _ and __ .
C has a problem: When you #include a header like <stdio.h>
your program suddenly acquires declarations of functions like
printf() and fopen() -- which is what you wanted -- but it
usually also acquires declarations of some of the private
details of the standard library. For example, <stdio.hmust
declare FILE* as a type, and quite often has to declare a FILE
struct to do so. Many <ctype.himpleme ntations declare special
arrays that describe the attributes of different character values.
And so on: C's problem is that it is difficult to declare all the
"public" stuff properly without making some of the "private" stuff
visible at the same time.

Why is that a problem? Some of the "private" stuff needs
names -- the names of the elements in a FILE struct, or of the
special <ctype.harray s, for example -- and chaos will result if
those names collide with others that the programmer has chosen for
his own purposes. If a hypothetical <ctype.hdid this:

extern char lower[1+256];
#define tolower(c) lower[1+(c)]

there would be trouble if your program started out with

#include <ctype.h>
int higher = 1;
int lower = -1;

because `lower' is being used to refer to two different things
and the uses can't be resolved contextually.

C "solves" this problem by dividing programmers into two
groups: Those who write the C implementation and those who use
C to write other things. The Standard then reserves one family
of identifiers for use by the implementors, and another family
for the users: The implementors may not use `lower' lest it clash
with an identifier a user might choose, and the users must not
use `_lower' because that's a name reserved for implementors' use.
(This is a slightly simplified version of affairs; the actual
situation is somewhat more involved. Roughly speaking, though,
users should not declare identifiers that start with underscores
and implementors should not declare identifiers that start with
letters -- there's a long list of exceptions and special cases,
but it's hardly worth trying to remember them all.)

So: When you see `extern struct _io _iob[3];' in a system
header this is *not* an encouragement to use names like _io and
_iob in your own code. Rather, it's the implementor staying out
of your way by using special names for the things he needs to
give names to.

--
Eric Sosman
es*****@acm-dot-org.invalid
Sep 25 '06 #5
g.*******@gmail .com wrote:
I have seen many variables or structures declared as _ or __ prefixed .
Can anyone explain the significance of _ or __ particularly . I mean ,
I wanted to know the convention for using _ and __ .
More specific answers to your query have been given elsethread, but one
thing you might want to keep in mind is that the underscore character is
allowable in a C identifier.

While this is an obvious statement, it highlights the fact that any
conventions and standards are just that; conventions we've placed on the
use of characters in C identifiers.
Sep 25 '06 #6
g.*******@gmail .com wrote:
>
kondal wrote:
g.*******@gmail .com wrote:
I have seen many variables or structures declared as _ or __ prefixed .
Can anyone explain the significance of _ or __ particularly . I mean ,
I wanted to know the convention for using _ and __ .
There is no particulat meaning in using _ or __ except that of a
general convention used to identify system variables/functions by
single underscore and metadata identified by double underscored.

-kondal

Thanks for your reply. But ould you please explain metadata in a bit
detail.
The point though, according to the rules of the language,
is that identifiers which are prefixed by _ or __
are "reserved identifiers" with some exceptions,
and that you should generally avoid using them.

--
pete
Sep 25 '06 #7
On 25 Sep 2006 03:45:15 -0700, "kondal" <ko******@gmail .comwrote in
comp.lang.c:
>
g.*******@gmail .com wrote:
I have seen many variables or structures declared as _ or __ prefixed .
Can anyone explain the significance of _ or __ particularly . I mean ,
I wanted to know the convention for using _ and __ .

There is no particulat meaning in using _ or __ except that of a
general convention used to identify system variables/functions by
single underscore and metadata identified by double underscored.
You are completely wrong. There is no "general convention". There is
a namespace reserved for the implementation by the C language
standard.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
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
Sep 26 '06 #8

Jack Klein wrote:
On 25 Sep 2006 03:45:15 -0700, "kondal" <ko******@gmail .comwrote in
comp.lang.c:

g.*******@gmail .com wrote:
I have seen many variables or structures declared as _ or __ prefixed .
Can anyone explain the significance of _ or __ particularly . I mean ,
I wanted to know the convention for using _ and __ .
There is no particulat meaning in using _ or __ except that of a
general convention used to identify system variables/functions by
single underscore and metadata identified by double underscored.

You are completely wrong. There is no "general convention". There is
a namespace reserved for the implementation by the C language
standard.
I used the phrase 'general convention' because C language doesn't stop
me in using a underscore in variables. How can you say it is reserved
namespace only for the C language standard and usable only by the C
language implementors.

-kondal

Sep 26 '06 #9

g.*******@gmail .com wrote:
kondal wrote:
g.*******@gmail .com wrote:
I have seen many variables or structures declared as _ or __ prefixed .
Can anyone explain the significance of _ or __ particularly . I mean ,
I wanted to know the convention for using _ and __ .
There is no particulat meaning in using _ or __ except that of a
general convention used to identify system variables/functions by
single underscore and metadata identified by double underscored.

-kondal

Thanks for your reply. But ould you please explain metadata in a bit
detail.

Ankush
metadata is nothing but 'data describing data'. It is useally used for
data processing systems/protocols where you have data that can fit to a
structure. This structure is dynamically created using another
sturcture which is called metadata.

Its like XML describes the data and XML scheme definition (I suppose
that is what it is called) describes the XML.

-kondal

Sep 26 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1911
by: Anonymous | last post by:
In PHP Whats the difference between $yourname = @$_POST; AND $yourname = $_POST; In particular, what is the significance of '@' as a prefix to the variable? Thanks in advance
4
2589
by: Prem Mallappa | last post by:
Hello can anybody please tell me what is the significance of 0; 1; or something like 100;
2
2597
by: Prem Mallappa | last post by:
what is the significance of 0; 1; or 100;
5
2834
by: kernel.lover | last post by:
hello, I want to know if a fuction say malloc is declared as void *malloc() then whats the significance of void here. Does void * is used when function has the flexibility to return any type of value by casting that functions with appropriate data type?
4
1266
by: Frank Rizzo | last post by:
In some examples with inheriting, I see the overloaded function always call its base. For instance, in this case where the ListView control is being extended. public class ListViewEx : System.Windows.Forms.ListView { protected override void OnColumnClick(ColumnClickEventArgs e) { ...various code to extend the control
2
1502
by: | last post by:
What is the significance in using MVC architechture in Dotnet? I think the framework itself is based on MVC The view being the Asp.Net The Controller being the code-behind file .... Is that so?
26
1541
by: joe | last post by:
My experiments show that the random number generator in Microsoft's VC++6 compiler is a statistical RNG with a significance level 1.0%. Statistical testing at SL >1.0% (for example 1.001%) passes the test, but 1.0% does not pass... Can anybody confirm this finding? The RNG function of the various SW products can be analyzed and classified better using its significance level
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.