tags:

views:

80

answers:

1

How do I pass or get parameter values to/from this function pointer:

typedef void(*  CreateCursorBitmapProc )(uchar *bitmapBuffer, uint32 *width, uint32 *height, bool16 *hasAlpha)

bitmapBuffer, width, height, hasalpha are the out parameters.

+2  A: 
// Grab an instance from somewhere...
CreateCursorBitmapProc instance = ...;

// Declare output variables
// should be initialized to some buffer, probably
uchar *bitmapBuffer = new uchar[size_of_buffer]; 
uint32 width, height;
bool16 hasAlpha;
(*instance)(bitmapBuffer, &width, &height, &hasAlpha);
Mehrdad Afshari
Why not just instance() - why dereference the pointer?
sharptooth
@sharptooth: Those are equal. I think I've had bad experiences without dereferencing in crappy compilers that made me stick to this syntax. I'm not really sure why. Anyway, it's a matter of style.
Mehrdad Afshari