News for hackers. Stuff that matters.
Re:C puzzles by nickff on Thursday November 10, 2016 @12:21PM (#12922259)
I agree with you on some counts, but not on others.

  unsigned int countBits (unsigned int x)
  {
      int i;
      int shift; // number of positions to shift to the right
      static unsigned int mask[] = {
      0x55555555,
      0x33333333,
      0x0F0F0F0F,
      0x00FF00FF,
      0x0000FFFF};

      for (i = 0, shift = 1; i < 5; i++, shift *= 2)
          x = (x & mask[i]) + ((x >> shift) & mask[i]);

      return x;
  }
Where to put the first '{' depends on your development environment, as some hide the line where the bracket is, and some don't (when you hide a function or loop). Array initialization format is a tricky one, as the spacing is very dependent on how you are trying to visualize the data, but I would agree that all (leftmost) elements should be aligned to the same margin. I find the blank line between array and other declarations puzzling for both examples. I prefer to leave blank lines between code of the same indent (outside of declarations and initializations). Commenting using '//' allows you to comment out blocks of code on both sides of your line comment, so I'm with you there.

P.S. I do not like Hacker News' paragraph formatting

Re:C puzzles by CapacitorSet on Thursday November 10, 2016 @03:28PM (#12924013)
I wouldn't mind working with your coding style either: though I don't have the same standards for braces and array initialization, you apply your style consistently across the whole code.