1166
Tell me the truth ... (piefed.jeena.net)
you are viewing a single comment's thread
view the rest of the comments
[-] skisnow@lemmy.ca 53 points 2 months ago

Back in the day when it mattered, we did it like

#define BV00		(1 <<  0)
#define BV01		(1 <<  1)
#define BV02		(1 <<  2)
#define BV03		(1 <<  3)
...etc

#define IS_SET(flag, bit)	((flag) & (bit))
#define SET_BIT(var, bit)	((var) |= (bit))
#define REMOVE_BIT(var, bit)	((var) &= ~(bit))
#define TOGGLE_BIT(var, bit)	((var) ^= (bit))

....then...
#define MY_FIRST_BOOLEAN BV00
SET_BIT(myFlags, MY_FIRST_BOOLEAN)

[-] ethancedwards8@programming.dev 4 points 2 months ago

Okay. Gen z programmer here. Can you explain this black magic? I see it all the time in kernel code but I have no idea what it means.

[-] ssfckdt@lemmy.blahaj.zone 1 points 2 months ago
load more comments (2 replies)
load more comments (4 replies)
this post was submitted on 15 May 2025
1166 points (98.6% liked)

Programmer Humor

25312 readers
275 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