cevou
cevou

Reputation: 325

Typedef for existing DLL function returns function error

I want to use a DLL in my program which has a function

void Set_Callback(Function Pointer)

The example code inserts a typedef which obiously doesn't work with my VS C++ 2010

typedef void (SET_CALLBACK)(void far pascal (*lpfnPtr)(int));

For this line I get an syntax error '*' and 'function returns function' error.

thanks for your help in advance

Upvotes: 0

Views: 782

Answers (2)

Kit Fisto
Kit Fisto

Reputation: 4515

It should be

typedef void far pascal (*CallbackType)(Function*);

Upvotes: 0

Necrolis
Necrolis

Reputation: 26181

Its easier to understand and read if you break it into two typedefs:

typedef void (__stdcall * Function)(int);
typedef void (* SETCALLBACK)(Function pf);

in the first typedef, pascal becomes __stdcall (as pascal was for older 16bit systems), and far can be dropped as it is superfluous in 32/64-bit architectures

Upvotes: 1

Related Questions