this post was submitted on 15 May 2025
1136 points (98.5% liked)

Programmer Humor

25567 readers
861 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] KindaABigDyl@programming.dev 184 points 2 months ago (5 children)
typedef struct {
    bool a: 1;
    bool b: 1;
    bool c: 1;
    bool d: 1;
    bool e: 1;
    bool f: 1;
    bool g: 1;
    bool h: 1;
} __attribute__((__packed__)) not_if_you_have_enough_booleans_t;
[–] xthexder@l.sw0.com 41 points 2 months ago* (last edited 2 months ago) (1 children)

Or just std::bitset<8> for C++. Bit fields are neat though, it can store weird stuff like a 3 bit integer, packed next to booleans

[–] Sonotsugipaa@lemmy.dbzer0.com 10 points 2 months ago* (last edited 2 months ago)

That's only for C++, as far as I can tell that struct is valid C

load more comments (3 replies)