Link to home
Start Free TrialLog in
Avatar of myson
myson

asked on

VC++ and error C2664

Hi!
I've got VC++ 5.0 and a following code:

//function prototypes
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK       EnumWndAtch (HWND, LPARAM);

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    ....
    //here I call EnumWndAtch function
    EnumWindows(EnumWndAtch, TRUE);
    ....
}
//called function
BOOL CALLBACK EnumWndAtch(HWND hwnd, LPARAM lParam)
{
    ....
}

When I have this code in a .cpp file, I will get a compiler error:
error C2664: 'EnumWindows' : cannot convert parameter 1 from 'int (void *,long)' to 'int (__stdcall *)(void)'.
But when I rename a .cpp file to a .c file, it works. But I want to use C++ enhancements, whitch i cannot use in a .c file.
I tried it with an extern "C" command, but it still didn't work. It's sure easy, but I can't think up how to use this code in C++.
Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of myson
myson

ASKER

Thanks a lot, nietod! You're a genius.
A genius?

Ahh that explains it.  The reason all the IQ tests-WISC, WASE, WIPSE--all begin with W. W is for windows.   :-)