I'm trying to write a callback function, I've done it before,
but this time I seem to be having problems...

I define the following...

typedef int (* ENUMINTERFACE)(char* szIP);
void enumInterfaces(ENUMINTERFACE pFn);
int InterfaceEnumProc(char* szIP);

then at some point in my code I call
enumInterfaces(InterfaceEnumProc);

I get the compilation error
'cannot convert parameter 1 from int(char*) to int(_cdecl*)(char*)

whats the correct form for declaring callbacks.

Mark

Re: problems with callback function by Scot

Scot
Tue Jul 26 15:01:12 CDT 2005

It appears to me that your project's calling convention is set to something other than _cdecl.
Perhaps you have it set to _stdcall?

"Mark" <mswinson@REMOVETHISBITbtinternet.com> wrote in message
news:eaaP9lhkFHA.2608@TK2MSFTNGP14.phx.gbl...
> I'm trying to write a callback function, I've done it before,
> but this time I seem to be having problems...
>
> I define the following...
>
> typedef int (* ENUMINTERFACE)(char* szIP);
> void enumInterfaces(ENUMINTERFACE pFn);
> int InterfaceEnumProc(char* szIP);
>
> then at some point in my code I call
> enumInterfaces(InterfaceEnumProc);
>
> I get the compilation error
> 'cannot convert parameter 1 from int(char*) to int(_cdecl*)(char*)
>
> whats the correct form for declaring callbacks.
>
> Mark
>
>
>



Re: problems with callback function by Mark

Mark
Tue Jul 26 15:19:57 CDT 2005

> It appears to me that your project's calling convention is set to
> something other than _cdecl. Perhaps you have it set to _stdcall?

no, for the file in question the calling convention is set to _cdecl.


Mark



Re: problems with callback function by Scot

Scot
Tue Jul 26 15:55:13 CDT 2005

It's common for callback functions to use _stdcall instead of _cdecl. Try explicitly declaring
__stdcall
typedef int (__stdcall * ENUMINTERFACE)(char* szIP);
int __stdcall InterfaceEnumProc(char* szIP);

"Mark" <mswinson@REMOVETHISBITbtinternet.com> wrote in message
news:ehLEv%23hkFHA.2444@tk2msftngp13.phx.gbl...
>> It appears to me that your project's calling convention is set to something other than _cdecl.
>> Perhaps you have it set to _stdcall?
>
> no, for the file in question the calling convention is set to _cdecl.



Re: problems with callback function by Mark

Mark
Tue Jul 26 16:16:25 CDT 2005

> It's common for callback functions to use _stdcall instead of _cdecl. Try
> explicitly declaring __stdcall
> typedef int (__stdcall * ENUMINTERFACE)(char* szIP);
> int __stdcall InterfaceEnumProc(char* szIP);
>

I tried that, I just got the same error - but with stdcall in place of
_cdecl
e.g
cannot convert parameters 1 from int (char*) to int (_stdcall*)(char*)





Re: problems with callback function by Scot

Scot
Tue Jul 26 16:31:00 CDT 2005

Mark,
I just copied and pasted your original code into my own application. Of course, I got an
unresolved external linker error, because I hadn't implemented the function, but it complied without
a problem.
I'm still suspecting that it is some project- or file-level setting that is confusing it.

"Mark" <mswinson@REMOVETHISBITbtinternet.com> wrote in message
news:e$%23KTeikFHA.3288@TK2MSFTNGP09.phx.gbl...
>> It's common for callback functions to use _stdcall instead of _cdecl. Try explicitly declaring
>> __stdcall
>> typedef int (__stdcall * ENUMINTERFACE)(char* szIP);
>> int __stdcall InterfaceEnumProc(char* szIP);
>>
>
> I tried that, I just got the same error - but with stdcall in place of _cdecl
> e.g
> cannot convert parameters 1 from int (char*) to int (_stdcall*)(char*)
>
>
>
>