Daniel Rogers

Bit declirations and changing values

Discussion created by Daniel Rogers on Nov 18, 2007
Latest reply on Nov 19, 2007 by CrasyCat
I have a bit array set up of about 66 bits. Mem map says 9 bytes.

decleared as below.

typedef struct _B
  unsigned bSizerStatus:1;                  // sizer status - running,stopped
  unsigned bSizerStatusChg:1;              // sizer status - running,stopped
  unsigned bSizerDataUpdate:1;
  unsigned bDiagDataUpdate:1;              // sizer status - running,stopped
  unsigned bSizerSpeed:1;                  // speed update flag
  unsigned bWghReq:1;
  unsigned bBkLightTimerReset:1;
  unsigned bAllCupReq:1;
  unsigned bTestAll:1;
  unsigned bTestSingleLane:1;

I have a routine that calls an other and in that routine it sets one ofr these bits upon returning it tests that bit to see if it is set and carries on.

The problem is it sets the bit but by the time it comes to test it it is cleared.


If define it as "uchar x; ie a unsigned byte which is a waste of memory it works fine.