r/programming • u/chaobang • Aug 22 '26
The unlikely Linux macro
https://rushed-reflections.bearblog.dev/an-unlikely-experiment/Wrote a bit about the `unlikely` and `likely` macros in the Linux codebase. Great little exploration into tiny optimizations that everyone should know more about 😄
187
Upvotes
View all comments
Show parent comment
1
u/_Noreturn Aug 23 '26
I mean I could nitpick and say C allows like a million ways to implement a thing unlike C++ e.g inheritance you could do it with the first object trick and function pointers or allocate dynamicly vis the last member trick and use a global vtable. In C++ it would just be inheritance which is universal.
Or how to name functions e.g object_create or object_new? in C++ it is always called a constructor.
As always set a style guide
Lets be honest that the C++ standard is irrelevant, you are the kernel you define the spec basically and you could rely on gcc extensions.
Also the C++ standard buzzwords practically translats to "your moved from object should be destructible" as that is what only realistically matters.