Function pointer is saying invalid declation

I have two functions
BOOL WINAPI DrawXY(HDC hdc,int x,int y,PMWIMAGEHDR pimage){ ..}, and
BOOL WINAPI DrawXYResized(HDC hdc,int x,int y,PMWIMAGEHDR pimage){ ..}


I want to make a function pointer to switch the function at run time. So I made a declaration of the function pointer as below and using.
BOOL WINAPI (*DrawABC)(HDC hdc,int x, int y,PMWIMAGEHDR pimage);
.
.
.
.
if<somecondition>
DrawABC=DrawXY;
else
DrawABC=DrawXYResized;


This code is working fine when building in linux, but failing in windows environment at compile time.It is giving error C2059: syntax error : '('

Please suggest here.

Jay Prakash Tiwari
Last edited on
Since you don't show your actual code we are unable to point out the problem. You need to show the code the compiler is complaining about. Also note that strictly speaking you should say DrawABC = &DrawXY;.
BOOL WINAPI (*DrawABC)(HDC hdc,int x, int y,PMWIMAGEHDR pimage);

This is wrong. The WINAPI needs to be after the ( but before the * like so:

BOOL (WINAPI *DrawABC)(HDC hdc,int x, int y,PMWIMAGEHDR pimage);

Why? I have no idea, this is just how the syntax is designed.
Last edited on
Topic archived. No new replies allowed.