On Thu, Jan 29, 2026 at 01:53:08AM +0100, Vincent Lefevre wrote: > On 2026-01-28 15:46:08 -0500, Derek Martin wrote: > > - many, many developers (myself included, but also almost everyone > > I've worked with) find 2 spaces inadequate for indentation, most > > especially (but not exclusively) in longer functions with more > > than 2 or 3 levels of indentation. If you're not one of those, > > bully for you, but don't make the rest of us suffer. Please, use > > a minimum of 4. > > Said like that, this does not make much sense, because there are > several ways to indent. For instance:
Except I indicated W. Richard Stevens' style is perfect. So if you've ever seen any of his stuff, you knew what I meant. I'm fairly certain you have. If you haven't, you can find examples of it online. > and (GNU-style indentation) ...is poison. It wastes lines on the open paren, does not line up the end of the block with the start of the block, and otherwise is the same as indenting 4 spaces. So just skip the silly paren alignment and use 4 spaces. Whoever came up with this style was clearly on cocaine. > A higher number of spaces would be an issue if there are many nested > loops and if-tests I said that. > > GNU is an abomination, > > I disagree. I'm shocked! =8^X > > which is why you pretty much never see it outside GNU projects > > or projects of MIT grads... Pretty much never in books. > > > > - sizeof IS NOT A FUNCTION[*]. Do not format it like one, i.e. use: > > ✓ sizeof varname // no, doesn't need parens > > ✓ sizeof (type name) // parens needed, but not a function call! > > ✓ struct foo *x; size_t s = sizeof *x; // doesn't need parens or to be > > initialized/non-null! > > But this can be error-prone. In exactly the same way as every other expression if you don't know the order of precedence. This requires parens to get that right, IF you need a different order of evaluation, or it requires you to know the order of precedence. As always. You can, of course, add parens for clarity, if you think that will help, but you shouldn't have to if they are unnecessary. This has nothing to do with whether to use parens for sizeof as standard. -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience.
