this post was submitted on 15 May 2025
191 points (96.1% liked)

Programmer Humor

37208 readers
317 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] jsomae@lemmy.ml 26 points 2 months ago* (last edited 2 months ago) (6 children)

Use bit-fields:

struct {
  bool a : 1;
  bool b : 1;
  bool c : 1;
  //...
};

Edit: careful not to use a 1-bit signed int, since the only values are 0 and -1, not 0 and 1. This tripped me up once.

[–] Strawberry@lemmy.blahaj.zone 2 points 2 months ago (4 children)

In a world where a bigger memory chip is more expensive by only a few cents where this would be most useful, is this feature still relevant?

[–] kora@sh.itjust.works 5 points 2 months ago* (last edited 2 months ago)

Yes, firmware running on bare metal requires good resource management. My current development board processor contains 512KB SRAM. That's equivalent to half of the size of an average PDF.

load more comments (3 replies)
load more comments (4 replies)