r/ProgrammerHumor • • Oct 04 '26

Meme architectureDependentChars

Post image
3.0k Upvotes

372 comments sorted by

View all comments

Show parent comment

34

u/Wertbon1789 Oct 05 '26

sizeof is more like an operator than a function. You can actually write sizeof without braces. There's nothing to optimize out, it's by design a compile-time constant expression. It's like a fancy way to write a scalar.

-1

u/MateoConLechuga Oct 05 '26

You can only omit the parentheses if it is a variable, not a type. It's also not always a compile-time constant, e.g. VLAs. So basically everything you said is wrong.

7

u/Wertbon1789 Oct 05 '26

Damn, I didn't even know the VLA thing. Didn't have that many meaningful interactions with VLAs. And yes, the caveat that sizeof doesn't need braces only when used with expressions is an important note. Didn't know that, as you typically always just use braces anyways. Fair enough, you never stop learning stuff.