Re:C will never stop you from making mistakes
by 0xffff2 on Monday August 10, 2020 @10:49AM
(#24109842)
I'm a C++ guy who prefers `int*`. I also hate multiple declarations on a single line so I just outlaw that entirely so I never have an issue with declaration correctness.
[ Parent
| on HN ]
Re:C will never stop you from making mistakes
by ramzyo on Monday August 10, 2020 @11:38AM
(#24110436)
Three cheers for pointing out that this boils down to preference. In years programming C in teams and projects of various sizes and criticality, I've never come across a situation where the asterisk position actually made a difference, other than to incite grumbles from those who prefer it whatever which way. I sincerely look forward to a situation where it does make a difference to the maintainability or correctness of code in a way that can't be addressed with other language syntax, or impedes a team's ability to deliver reliable production software against whatever style guide or coding standard they've adopted.
Re:C will never stop you from making mistakes
by Ragnarork on Monday August 10, 2020 @11:56AM
(#24110632)
I'm in the same boat, and I'd like to add that I agree that using `int* p, * q, * r;` is not pretty, and could possibly lead to ending up mistakenly with `int* p, q, r;`.
But we're in 2020 and we've learned to avoid to declaring stuff without initializing it at the same time to avoid the stupid mistake of using something uninitialized.
Interestingly enough, testing with clang shows that uninitialized variables get their warning, but uninitialized raw pointers don't.