News for hackers. Stuff that matters.
Re:Modern Pascal is still in the race (2022) by kazinator on Wednesday October 11, 2023 @11:08PM (#37853071)
Because the syntax is:

  <specifiers> <declarator> {, <declarator>, ...} ;
The star is a type-deriving operator that is part of the <declarator>, not part of the <specifiers>!

This declares two pointers to char:

  char *foo, *bar;
This declares foo as a pointer to char, and bar as a char:

  char* foo, bar;
We have created a trompe l'oeil by separating the * from the declarator to which it begins and attaching it to the specifier to which it doesn't.
Re:Modern Pascal is still in the race (2022) by mikewarot on Thursday October 12, 2023 @05:36AM (#37855117)
>This declares foo as a pointer to char, and bar as a char:

  char* foo, bar;
So that's why I've had so many problems understanding C. I come from the Pascal world, where a type specification is straightforward.
Re:Modern Pascal is still in the race (2022) by mikepurvis on Thursday October 12, 2023 @10:10AM (#37857412)
On the other hand, for those of us who agree with the GP on this, one way around the pitfall is to have your project's style guide ban multiple declarations on a single line, or at least ban them for non-trivial variables— so `int x, y, z;` is permitted, but nothing more than that.
Re:Modern Pascal is still in the race (2022) by kazinator on Thursday October 12, 2023 @11:23AM (#37858508)
That's fine if it isn't used as a pretext for writing nonsense like char* p;.