Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/27/11 20:47
Read: times


 
Msg Score: -1
 -1 Answer is Wrong
#183089 - Bit Fields
Responding to: ???'s previous message
Hi

One way to do it is usning C bit field construct.



# define CLEAR (0)
# define SET (1)


typedef struct 
{
   unsigned int bit1: 1;
   unsigned int bit2: 1;
   unsigned int bit3: 1;
   ........

 } Bits;


Bits BitFields;



BitFields.bit1 = SET;
BitFields.bit1 = CLEAR;







but the implementation of the construct is platform dependent. Further even a single bit will take atleast one word and if you have enough fields they are packed in the word until all bits are exausted then second word and so on. If compiler is smart enough and bit manipulation instructions are supported this is pretty fast,readable and portable code.




List of 12 messages in thread
TopicAuthorDate
Bit variable in KEIL Arm            01/01/70 00:00      
   Hw bit variables normally not available in processors            01/01/70 00:00      
      Not quite true.            01/01/70 00:00      
         He covered that            01/01/70 00:00      
   Choice of forum            01/01/70 00:00      
   bool            01/01/70 00:00      
      bool is nothing specifically to do with single-bit variables            01/01/70 00:00      
         Not wrong            01/01/70 00:00      
            Yes - wrong!            01/01/70 00:00      
               bit != bool even if nominal storage range is same            01/01/70 00:00      
   Bit Fields            01/01/70 00:00      
      Wrong answer for this question            01/01/70 00:00      

Back to Subject List