|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
PPC bool bitfield
I was working on a library to make some tasks easier on the cRIO, and the library contained a bitfield that looks like this:
Code:
union ORArgs
{
unsigned char Value;
struct b
{
bool b0 : 1,
b1 : 1,
b2 : 1,
b3 : 1,
b4 : 1,
b5 : 1,
b6 : 1,
b7 : 1;
} Bits;
};
|
|
#2
|
|||||
|
|||||
|
Re: PPC bool bitfield
I don't think either is correct.
The ": 1" part of the definition specifies how many bits wide to make the element. If the compiler does what it is hinted to do, the eight booleans will take up exactly one byte. That will map precisely onto the one-byte char also defined in the union. |
|
#3
|
||||
|
||||
|
Re: PPC bool bitfield
Since you're specifying the type "bool", I believe the first four make up one bool variable, and the next 4 make up a second bool variable. If you made it a 10-bit bitfield, you'd end up with bool variables and 2 unused bits. At least, that's my understanding. From what I've read on bitfields, that code should be fine. The variable type declarations are really more just the computer's version of bureaucracy, it tells it how to write the memory addresses.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PPC 970FX Beats P4 and AMD64 | Joe Matt | Chit-Chat | 4 | 14-02-2004 14:52 |
| bool Variables, Autonomous Mode | lasindi | Programming | 6 | 22-01-2004 22:26 |