4 ms·
It's always the same for your compiler. Using sizeof improves the portability of the code. Because sizeof is calculated at compile time it doesn't make the code
by fredophile 12y ago
It's always the same for your compiler. Using sizeof improves the portability of the code. Because sizeof is calculated at compile time it doesn't make the code any less efficient.
We often think about pointers as being 4 bytes but that isn't necessarily the case. How would a 32 bit pointer map to the addressable memory of 64 bit hardware?
- reubenmorais 12y agoI think his point is more about clamping the value than about using sizeof. It indicates the author expected that value to vary, but it doesn't.
- fredophile 12y agoDepending on your application I can see where you might still want to clamp the result. However, I think you're right in this case since the clamped range doesn't make much sense here.