View Single Post
  #1   Spotlight this post!  
Unread 21-06-2009, 19:59
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
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;
};
later, I read that bools are 4 bytes on a PPC system, which we have in the crio, and was wondering if the four bytes would cause undesired effects, like set b0,b1,b2, and b3 to true if b1 is set to true, but after thinking about it for a while, I thought that the first bit of bool b0 would equal the first bit of char Value, and the rest of the bits would be "discarded". unfortunately, I won't have access to the cRIO for another week. Is my first thought or second thought the true one?
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote