It depends on why you are doing this. Typically, you cannot use types less than 8 bits because this is the address unit for the architecture. However, you can use structures to define different lengths:
struct s { unsigned int a : 4;
However, there is no guarantee that the structure will be 24 bits long. In addition, this can lead to problems from the side. Where you can, it is best to use system independent types like uint16_t etc. You can also use bitwise operators and bit shifts to deceive things very much.
Whirlwind
source share