473,883 Members | 1,872 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 11194

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
1913
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
2594
by: Prem Mallappa | last post by:
Hello can anybody please tell me what is the significance of 0; 1; or something like 100;
2
2598
by: Prem Mallappa | last post by:
what is the significance of 0; 1; or 100;
5
2841
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
1270
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
1503
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
1547
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
9796
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10757
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
10860
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
10420
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9583
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7975
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7134
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
5804
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
6002
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.