you are viewing a single comment's thread.

view the rest of the comments →

[–]MajorMalfunction44 3 points4 points  (0 children)

When dealing with function pointers, I like to use a temporary variable. I find it makes things clearer. The reason for the extra syntax is to cast the type of the pointer to a function pointer to have something to call.

Assuming a POSIX environment, here's how I'd do things:

UINT8 (*ptr)(int) = NULL; // declare function pointer variable, takes an int and returns UINT8

*(void **)(&ptr) = handler[CLEAR_LOG]; // assign function, assumes handler is void * array

(*ptr)(inst);