Re:Show HN: Cdecl-dump - represent C declarations visually
by saagarjha on Sunday December 07, 2025 @11:18PM
(#46188242)
Of course, the correct way to use a function pointer is to call it.
Re:Show HN: Cdecl-dump - represent C declarations visually
by nitrix on Sunday December 07, 2025 @11:19PM
(#46188249)
Yes, the () operator dereference function pointers automatically for you for convenience. There's also the surprise that you can infinitely dereference function pointers as they just yield you more function pointers.
Re:Show HN: Cdecl-dump - represent C declarations visually
by korianders on Monday December 08, 2025 @05:25AM
(#46190662)
One baffling thing I see people do with typedefing function pointers is insisting on adding in the pointer part in the typedef which just complicates and hides things.
If you want to typedef a function pointer, make a completely ordinary function declaration, then slap 'typedef' at the beginning, done. This does require you to do "foo_func *f" instead of "foo_func f" when declaring variables, but that is just clearer imo.
typedef int foo_func(int); // nice
typedef int (*foo_func)(int); // why?
Re:Show HN: Cdecl-dump - represent C declarations visually
by cryptonector on Monday December 08, 2025 @12:57PM
(#46195456)
Why do you need the `*` to be part of every variable/member declaration?
Re:Show HN: Cdecl-dump - represent C declarations visually
by any1 on Monday December 08, 2025 @01:13AM
(#46188970)
> It's the intended way to read/write declarations/expressions. As a consequence, asterisks ends up placed near the identifiers.
You know you don't always have to use things as they were intended?
> The confused ones will think it's a stylistic choice and won't understand any of this.
Well, I've written it both ways, and the compiler never seems to mind. :)
Maybe I should start putting space on both sides of the asterisk; seems like it would be a good way to annoy even more people.
Re:Show HN: Cdecl-dump - represent C declarations visually
by pwdisswordfishy on Monday December 08, 2025 @02:02AM
(#46189272)
Blame Stroustrup.
It's the intended way to read/write declarations/expressions. As a consequence, asterisks ends up placed near the identifiers. The confused ones will think it's a stylistic choice and won't understand any of this.