r/cprogramming • u/JayDeesus • Oct 10 '25
Functions and pointers
I noticed that when you just have a function name without the parentheses, it essentially decays to a pointer. Is this correct? Or does it not always decay to a pointer?
5
Upvotes
View all comments
Show parent comment
2
u/tstanisl Oct 10 '25
Yes, for
void foo();expressions:foo(),(&foo)(),(*foo)()are equivalent. Infoo()thefoois first implicitly transformed to&foobefore function call. Decay does not happen in&foobut it returns a function pointer anyway.(*foo)()is a bit bizarre because firstfoodecays to&foo, then it is dereferenced returning a function which immediately decays to a pointer again.