Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > What does this (unusual?) structure definition mean?

Reply
Thread Tools

What does this (unusual?) structure definition mean?

 
 
Frederiek
Guest
Posts: n/a
 
      07-11-2006
Hi,

What exactly does the following code mean? More specific, what are the
colons for? Is this some kind of way to initialize the structure
members?

struct somestruct
{
unsigned char a:1;
unsigned char b:1;
unsigned char c:1;
};

Regards,

Frederiek

 
Reply With Quote
 
 
 
 
Jewel
Guest
Posts: n/a
 
      07-11-2006

Frederiek wrote:
> Hi,
>
> What exactly does the following code mean? More specific, what are the
> colons for? Is this some kind of way to initialize the structure
> members?
>
> struct somestruct
> {
> unsigned char a:1;
> unsigned char b:1;
> unsigned char c:1;
> };
>
> Regards,
>
> Frederiek


Look in your favorite reference for bitfields.

 
Reply With Quote
 
 
 
 
BigBrian
Guest
Posts: n/a
 
      07-11-2006

Frederiek wrote:
> Hi,
>
> What exactly does the following code mean? More specific, what are the
> colons for? Is this some kind of way to initialize the structure
> members?
>
> struct somestruct
> {
> unsigned char a:1;
> unsigned char b:1;
> unsigned char c:1;
> };
>
> Regards,
>
> Frederiek


It's declaring a bit field.

-Brian

 
Reply With Quote
 
Jakob Bieling
Guest
Posts: n/a
 
      07-11-2006
Frederiek <> wrote:

> What exactly does the following code mean? More specific, what are the
> colons for? Is this some kind of way to initialize the structure
> members?
>
> struct somestruct
> {
> unsigned char a:1;
> unsigned char b:1;
> unsigned char c:1;
> };


It's called a bit-field. a, b and c are each one bit (that is what
the number after the colon means).

regards
--
jb

(reply address in rot13, unscramble first)


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run-time template list definition / Run-time variable type definition Pierre Yves C++ 2 01-10-2008 02:52 PM
Automagic determination of definition based on definition location. Jon Slaughter C++ 4 10-26-2005 05:00 PM
can a class definition inside another class's definition Jianli Shen C++ 1 03-13-2005 06:02 PM
help?: incomplete definition with complete definition in scope Ark C Programming 1 08-07-2004 04:21 PM
Schema definition for a generic XML structure Ben XML 1 07-31-2003 01:20 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57