Earlier quoted context omitted.
Personally I don't like when people hide a pointer behind a typedef. If you want to use a typedef, typedef the function and then declare a pointer to that: typedef int func(void); func *func_ptr; Avoids the mess of the function pointer syntax, but still makes the fact that it is a pointer clear.
19 years as a C/C++/ObjC developer, and this never occurred to me. And it works with C Blocks! typedef int IntegerProcessor(int); int executeTheFunctionPointer(IntegerProcessor* function) { return function(23); } int executeTheBlock(IntegerProcessor^ block) { return block(32); } int doubler(int a) { return a * 2; } int main(int argc, const char * argv[]) { IntegerProcessor* myFunctionPtr = &doubler; int a = executeTh…
IntegerProcessor^ myBlock = ^(int b) {
return a * b;
};
I wasn't aware C supported nested functions.