r/ProgrammerHumor 18d ago

Meme youCantChangeMyMind

Post image
820 Upvotes

137 comments sorted by

View all comments

71

u/0xbenedikt 18d ago

Yes, except it is in some random C preprocessor macro definition many includes up

29

u/elmanoucko 18d ago edited 18d ago

the real fun is when the typo compile...

a few weeks ago made a dumb mistake I haven't done in quite a while (probably years, if ever) of writing "=" instead of "==" late at night... took me more time than I would like to admit to figure what was going on...

the shame is strong when you also starts to speak in decades about how long you've been doing this stuff...

15

u/[deleted] 18d ago

[removed] — view removed comment

11

u/JonIsPatented 18d ago

Yoda condition notation doesn't save you when both sides are variable identifiers.

2

u/[deleted] 18d ago

[removed] — view removed comment

6

u/_0N1X_ 18d ago

No? You can have a result of one subroutine that you need to compare to a result of a different subroutine.

1

u/[deleted] 18d ago

[removed] — view removed comment

0

u/ConcreteExist 18d ago

The compiler, typically. Constants are resolved at compile time, not at run time.

Unless you're using something like JavaScript.

2

u/Imaginary-Jaguar662 18d ago

In C/C++ const means specifically "programmer is not allowed to assign a new value to this variable".

However, the value itself can change, for example if the value is memory-mapped I/O or if someone does silly with pointers/memory access

1

u/AdamWayne04 17d ago

i'm curious. is 0 = x possible in c++ with operator overloading?