Its all fun and games until someone NULL's a valid pointer.
Spacing only matters as far as what doesn't hurt my eyes. I find huge indentations painful, and { on its own line ugly. More parenthesis are always good good in my book. It is better to type a few extra things then spend an hour debugging because you got an order of operations wrong.
if (test() && ((a+b)/d>c)) {
code;
//egads! 1 liner shouldn't have braces and is own line. I would only put it here for comment space.
//horizontal scrolling is bad, why the frak haven't they made a mouse with a scroll ball yet.
}
6 spaces, counting the cr/lf as spaces. 41 spaces if you count the ranting comments, and they are often present in my private code.
The whole debate over break, continue, if..else, and goto always makes me laugh. The first time I heard someone say goto was totally unnecessary was when Pascal had a solid footing and C was gaining steam. Some young kid thought he knew what he was talking about because he knew both languages. I shook my head and laughed since I knew they all got compiled to a jump/branch class of instruction. Then I learned Pascal; and thought well it is nice that the compiler handles most of it, and there aren't labels all over the place. Shortly followed by screaming, "There is no instruction to pop out of a loop. I have to set the control variable, WTF!"
I am not a huge fan of "while(1)", and prefer to use "for(;
". I have seen compilers reserve a register and test it when using the while. Probably another of those ancient things that finally got fixed.
Conversely I don't much like using "for" at any other time, and prefer to write out the loop parts. This is because "for" does its limit condition at the start; and just a little thought can determine if the loop will always run at least one pass. If it will make at least one pass then it makes more sense to use "do {} while;" It isn't just the 3 clock cycle gain, it is a logic hint for me when I have to look at that code again 5 years from now.
I have yet to see function, loop, or even memory alignment make a significant speed difference. If any one can point me to benchmarks demonstrating measured gains from alignment with the assembly being the exact same between the aligned and nonaligned tests; I would appreciate it.