Can someone please help me understand what the following line of code is doing?
typedef int (*test)(int);
Can someone please help me understand what the following line of code is doing?
typedef int (*test)(int);
First, figure it out without the typedef:
This makes test a pointer to a function (taking one int), and returning an int.Code:int (*test)(int);
When you add typedef to it, it means that “test” is now an alias for such a type. So you could do:
and now fun is a function pointer of the expected type.Code:test fun;
If you don't know how to decode declarations like this, the cdecl program can help you, if it's available for your platform.