File pointers and compile error c2440

P

Peter

Hi,

I am trying to compile an existing project (originally c) in .NET (rename .c
files to .cpp). After fixing some problems, here are the ones that I don't
know how to deal with:
--------------------------------------------------------------------------
....

.... \myfile.cpp(987) : error C2440: 'initializing' : cannot convert from
'int (__cdecl *)(mytype *,char *,int)' to 'int (__cdecl *)(void)'

None of the functions with this name in scope match the target type

....

----------------------------------------------------------------------------
-------------------------------------------------

The above error happened on a file pointer variable (on each function
address), which is as follows:

------------------------------

int (*fsm_ptr [ OP_MAX + 1 ] [ OP_MAX + 1 ] ) () = {

fsm_invalid, /* [sent = 0] [recv = OP_RRQ] */ // Line 987!

fsm_recv_RRQ, /* [sent = 0] [recv = OP_RRQ] */

fsm_recv_WRQ, /* [sent = 0] [recv = OP_WRQ] */

....

m_invalid, /* [sent = OP_ERROR] [recv = OP_DATA] */

fsm_invalid, /* [sent = OP_ERROR] [recv = OP_ACK] */

fsm_error /* [sent = OP_ERROR] [recv = OP_ERROR] */

};

The pointer variable was used in the main file like this:

....

retVal = (*fsm_ptr[pTd->op_sent][pTd->op_recv])(pTd,

pTd->recvbuff + OPCODE_BYTE_SIZE, nbytes - OPCODE_BYTE_SIZE);

....

--------------------------



Each function in the pointer is declared/implemented in the same file and
returns 0, -1, or -2. For example:

static int

fsm_invalid(struct mytype *pTd, char *ptr, int nbytes)

{

....


return ABORT;//Defined as -2

}



Can anybody help?


Thanks,

Peter
 
G

Gary Chang [MSFT]

Hi Peter,

Thanks for your response!

If you have built your project with /clr option, you can refer to the
following KB article:

PRB: LNK1254, LNK1284 and LNK1235 Linker Errors May Occur While Compiling a
C Source File with the /clr Compiler Option
http://support.microsoft.com/default.aspx?scid=kb;en-us;822329

Hope that helps!


Best regards,
Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top