Reputation: 6661
Was hoping someone could help me decipher this C snippet:
typedef int (DEFCALL *getFieldVal)(int key, int fieldSelect, char *name)
DEFCALL is defined earlier in the code, but only as
#define DEFCALL
So, I think DEFCALL
is just a blank, and I am effectively looking at
typedef int (*getFieldVal)(int key, int fieldSelect, char *name)
which defines getFieldVal as a pointer to a function that takes args int, int, and char*, and returns an integer. But the DEFCALL
has me wondering. Wanted to be sure.
Upvotes: 1
Views: 78
Reputation: 8160
The typedef
is defining a function pointer type. The DEFCALL
is a preprocessor macro that may be defined to specify any platform specific calling convention information used by the function. In this case it is defined as nothing resulting in the compiler generating the default calling convention, usually cdecl
.
Upvotes: 4
Reputation: 477650
The macro leaves room for adding a calling convention to the function type.
Upvotes: 6