473,397 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

what does this ":" in the structure ?

hi group

i read this in the linux version "tree" program

struct _info {
char *name;
char *lnk;
u_char isdir : 1;
u_char issok : 1;
u_char isexe : 1;
u_char isfifo : 1;
u_char orphan : 1;
u_short mode, lnkmode, uid, gid;
off_t size;
time_t atime, ctime, mtime;
dev_t dev;
ino_t inode;
#ifdef __EMX__
long attr;
#endif
};

can anyone tells me why is there a ":" in the structure and its use ?

thx

Oct 23 '07 #1
3 1359
David d'Angers said:
hi group

i read this in the linux version "tree" program

struct _info {
char *name;
char *lnk;
u_char isdir : 1;
Look up "bitfield" or "bit-field" in your C reference book. Bitfields are
sometimes used when a direct mapping to hardware bits is desired, but this
usage is inherently non-portable (not least because which way round the
bits go depends on the implementation). They are also sometimes used,
rather more portably, in an attempt to pack more than one numeric value
into a byte or group of bytes.

There is much more to be said about bitfields (mostly bad!, in my opinion),
but I think this short answer does at least address your question
sufficiently to enable you to discover more about them for yourself.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Oct 23 '07 #2
thx, i've found the corresponding section in the classical "the c
programming language"

Oct 23 '07 #3
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
They are also sometimes used,
rather more portably, in an attempt to pack more than one numeric value
into a byte or group of bytes.
That's the proper use of a bitfield. It's as portable as you can expect it
to be. The problem is that the compiler doesn't know whether you want
efficiency of packing or efficiency of access, and there is often a tension
between the two.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Oct 23 '07 #4

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

Similar topics

2
by: Angelos | last post by:
Ok... I have to make this administation area where I have multiple Contents to add edit delete publish . The problem is that I don't know what is the best way of making the forms. At the moment I...
6
by: Fred | last post by:
I have seen this syntax and would like to know weither var_name is entirely filled with zeroes or only a first few bytes are zeroed (for example the first field of the structure). I have of...
7
by: Warrax | last post by:
I am currently doing online tutorials for C++, and am pretty much stuck in a rut about this problem. It is saying that there's an expected unqualifed-id before '{' token (I will post the code in just...
4
by: lander | last post by:
I've read the page life cycle thing in msdn, still, i'm getting a bit confused of thinking how all the things are going under the hood... I know that when page loading, that the controls'...
9
by: erictheone | last post by:
Ok so what I'm trying to do is create a trans location cipher. For those among us that don't know alot about cryptography it is a method for jumbling up letters to disguise linguistic...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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...
0
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...

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.