5 ms·
Well... sizeof of an expression is mostly useful for not repeating yourself in cases when you need the size of a type you already have some way of referencing,
by ElectroPrime 14y ago
Well... sizeof of an expression is mostly useful for not repeating yourself in cases when you need the size of a type you already have some way of referencing, as in
a = malloc(sizeof(*a));
It's also useful for various hacks (stuff like compile-time assert macros), since it doesn't evaluate the expression, only its type.
- marshray 14y agoSure, I can think of plenty of ways it could arise via metaprogramming. I don't know if I would want such a warning enabled in my own template-heavy C++ code. But it perhaps it could be useful for those following the NetBSD style. :-)
- pizza_ 14y agosizeof is an operator, no need for the inner parens.