this post was submitted on 15 Jul 2025
460 points (94.9% liked)

Programmer Humor

37269 readers
23 users here now

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

Rules:

founded 6 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] Croquette@sh.itjust.works 7 points 5 days ago (1 children)

I am working with C in embedded designs and I still use 1 or 0 for a bool certain situations, mostly lines level.

For whatever pea-brained reason, it feels yucky to me to set a gpio to true/false instead of a 1/0.

[–] xthexder@l.sw0.com 6 points 5 days ago* (last edited 5 days ago) (1 children)

GPIOs are usually controlled by a single bit of a register anyway. Most likely you need to do something like:

// Set high
PORTB |= 1 << PINB5;
// Set low
PORTB &= ~(1 << PINB5);
[–] Croquette@sh.itjust.works 2 points 5 days ago (1 children)

I am a lazy dev (not really, clients always want fast code), so I use the provided HAL libraries 99.9% of the time.

But I have seen code where someone would write something like

gpio_write(PIN_X, true) 

and it always stood out to me.

[–] JackbyDev@programming.dev 1 points 5 days ago (1 children)

Define on as true or something? Or maybe that's more confusing. I'm not a C dev so I'm not gonna pretend to understand idiomatic microcontroller code lol.

[–] Croquette@sh.itjust.works 1 points 4 days ago

Sometimes, people do that. But using 0/1 is explicit enough since you can refer to a line as '1' or '0' for high/low on the hardware as well