Hacker News new | ask | show | jobs
by dailykoder 759 days ago
I think I've been writing C for well over 10 years now and this year was finally the one where I forced myself to remember function pointer declarations. I don't even know why it took me so long to remember such a simple thing, but possibly writing "c function pointer" into my favorite search engine and hitting enter was faster than thinking about it for a moment.

But maybe also because I changed up my general programming approach a bit and try to think a bit longer before hitting up a search engine. Also forced myself to read more reference sheets than stackoverflow or chatgpt. And I must say, this made me a lot more comfortable, because I understand more. Can recommend to go through the struggle/10

3 comments

I thought it was just me, that after 20 years of writing C I still have to look how to declare function pointers.
I'm weird that I have no problem getting function pointers but have to look up the syntax to declare an enum every damn time.
What i usually do is: Write a normal function declaration, prepend it with typedef and append _t to the function name. DONE

The same trick works for anything you want to typedef!

When they're function parameters, you can write them as regular function declarations, btw. ;) Might hurt your memorization efforts though.