What does this (unusual?) structure definition mean?
Question posted by: Frederiek
(Guest)
on
July 11th, 2006 04:15 PM
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
3
Answers Posted
Frederiek wrote:
Quote:
Originally Posted by
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.
Frederiek wrote:
Quote:
Originally Posted by
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
Frederiek <fd_news@hotmail.comwrote:
Quote:
Originally Posted by
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)
|
|
|
What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 196,987 network members.
Top Community Contributors
|