Is it possible to create a data type of length one bit in C

后端 未结 8 1954
醉话见心
醉话见心 2020-12-09 16:28

Esentially I want to create a data type uint1_t. Is that even possible?

I know the size of the bool data type is one byte. But boolean values only need

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-09 16:51

    The smallest object you can create has a sizeof == 1. That object will be CHAR_BIT bits in size, which on almost every platform you'll ever see, will be 8.

    So the smallest object you can create is a int8_t aka char.

    You can do things with bitfields to encode many 1 bit numbers into a larger object, but that's not exactly a solution to your problem.

提交回复
热议问题