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

后端 未结 8 1934
醉话见心
醉话见心 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:53

    Contrary to what some people believe, there is a data type of one bit in C99: it's called _Bool. You can also declare bitfields of size 1. The fact that individual bits are not addressable in C does not mean that one-bit data types cannot exist. That argument is basically comparing apples to oranges.

    There isn't, however, a type of which the storage size (sizeof) is less than one byte.

提交回复
热议问题