This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Question using bit variables

Hi,

I'm using the ST32F103G uC and Keli uVision 4.22 IDE.

Something that I don't understand is how to use single bits as variables or as a function return value. With other compilers I know 'bit' and 'bool' but somehow this doesn't seem to work with the armcc compiler. I searched the Internet but could not find anything in that direction.

Who can help me out?

Thanks in advance,

Henk

Parents
  • Most processors don't support bit variables, so there are no C language extension to declare bit variables or have function return single bits.

    You can manipulate bits in different ways, but if you have a boolean data type it will be larger than a single bit.

    The C++ bool data type is normally not a single bit. Many compilers implements it the same as an int. It's just that the compiler keeps track of the data type for improved type checking.

    If you do not want to manually perform bit-and/bit-or/bit-not you can play with bit fields - a method to create a struct where many narrow bit fields are stored in an integer container.

Reply
  • Most processors don't support bit variables, so there are no C language extension to declare bit variables or have function return single bits.

    You can manipulate bits in different ways, but if you have a boolean data type it will be larger than a single bit.

    The C++ bool data type is normally not a single bit. Many compilers implements it the same as an int. It's just that the compiler keeps track of the data type for improved type checking.

    If you do not want to manually perform bit-and/bit-or/bit-not you can play with bit fields - a method to create a struct where many narrow bit fields are stored in an integer container.

Children