logoalt Hacker News

viega • today at 1:51 PM • 0 replies • view on HN

A bool does automatically cast to an unsized bit slice.

Meaning, if you have a struct and you want to bit-pack your booleans, you can declare each one as, say, uint8_t some_bool : 1;

You may then do `x.some_bool = true;` etc.

It's a small nicety to avoid bitwise operators, anyway.