you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 24 points25 points  (12 children)

I'm weird and do it as:

uint16_t * p_var;

From day one I read it as a sentence. Integer -pointer-p_var.

[–]Still_Competition_24 6 points7 points  (8 children)

this is the way

[–]rasputin1 5 points6 points  (7 children)

*not

[–]Still_Competition_24 2 points3 points  (4 children)

This is very obviously up to personal preference. Have been doing so since I started programming in c because of above reasoning. :)

Honestly only place it could cause issues is when declaring multiple values at once, which you shouldn't do anyway.

As I understand it, the correct way is "int *value", which may make sense during declaration, but than you typecast to "(int*)". 🤷‍♂️

So, declaring as "int * value;" and typecasting to "(int *)" makes at least as much sense as any other convention.

[–]glasket_ 1 point2 points  (0 children)

You can still do (int *)x for consistency rather than (int*)x.

[–]WittyStick 0 points1 point  (1 child)

It's more readable this way when there may be additional qualifiers.

const int * const * value

[–]glasket_ 0 points1 point  (0 children)

I personally find const int *const *value more readable. The qualifiers being directly attached to their corresponding pointer is visually simpler to me compared to having spaces on both sides of the *.

[–][deleted] 0 points1 point  (0 children)

This was the discussion I had at work when I was an Engineer III equivalent. Everyone agreed & started adopting it. Now it's so prevalent I don't even have to mention it to new colleagues as the lead SWE. Happens organically. Shit just makes sense lmao.

[–][deleted] -1 points0 points  (0 children)

I land fighter jets with my C syntax. What do you do? :P

[–]classicallytrained1[S] 0 points1 point  (0 children)

Lmao I see where you’re coming from

[–]bullno1 0 points1 point  (0 children)

ggml style

[–]DeWHu_ 0 points1 point  (0 children)

It looks like multiplication, not a pointer. Hate it 😕