none
error C2664

    Question

  • Hi,

    VOID CALLBACK lineCallbackFunc(DWORD hDevice, DWORD dwMsg, DWORD dwCallbackInstance, DWORD dwParam1, DWORD dwParam2, DWORD dwParam3 )

    {

    }

    rc = ::lineInitializeExA(&hApp, ::GetModuleHandle(0), lineCallbackFunc, "", &nDevices, &version, &init);

    When compiling the application using VS2005 with 64 bit compiler I am getting this error "error C2664: 'lineInitializeExA' : cannot convert parameter 3 from 'void (__cdecl *)(DWORD,DWORD,DWORD,DWORD,DWORD,DWORD)' to 'LINECALLBACK' None of the functions with this name in scope match the target type".

    Please help anyone to resolve this error?

     

    Monday, March 12, 2012 12:17 PM

Answers

  • Thanks for your reply Gargo.

    After changing the datatype for 3 to 6 arguments of lineCallbackFunc as DWORD_PTR the error went off.

    • Proposed as answer by Helen Zhao Wednesday, March 14, 2012 6:51 AM
    • Marked as answer by Helen Zhao Monday, March 19, 2012 4:43 AM
    Monday, March 12, 2012 1:08 PM
  • You can try:

    rc = ::lineInitializeExA(&hApp, ::GetModuleHandle(0), (LINECALLBACK)lineCallbackFunc, "", &nDevices, &version, &init);




    • Edited by Bordon Monday, March 12, 2012 1:13 PM
    • Proposed as answer by Helen Zhao Wednesday, March 14, 2012 6:51 AM
    • Marked as answer by Helen Zhao Monday, March 19, 2012 4:43 AM
    Monday, March 12, 2012 1:12 PM
  • VOID CALLBACK lineCallbackFunc(DWORD hDevice, DWORD dwMsg, DWORD dwCallbackInstance, DWORD dwParam1, DWORD dwParam2, DWORD dwParam3 ) 

    This looks like the definition from the Windows Mobile 6 TAPI header. You want the Win32 TAPI header:

    typedef void (CALLBACK * LINECALLBACK)(
        DWORD               hDevice,
        DWORD               dwMessage,
        DWORD_PTR           dwInstance,
        DWORD_PTR           dwParam1,
        DWORD_PTR           dwParam2,
        DWORD_PTR           dwParam3
        );

    The DWORD is only unsigned long (32-bit) whereas the DWORD_PTR is unsigned __int64 (64-bit). 

    -PaulH

    • Proposed as answer by Helen Zhao Wednesday, March 14, 2012 6:44 AM
    • Marked as answer by Helen Zhao Monday, March 19, 2012 4:43 AM
    Monday, March 12, 2012 7:09 PM
  • Hi rmgs123,

    According to the document in MSDN Library, the third parameter of lineInitializeEx function is of LINECALLBACK type. If you want to know more information about this function, please refer to this link: http://msdn.microsoft.com/en-us/library/ms735983.aspx. Based on the codes you posted, I found that lineCallbackFunc is a callback function.

    Generally speaking, we have the following two ways to resolve C2664:
    1->Recheck the prototype for the given function and correct the argument noted in the error message.
     2->Supply an explicit conversion if necessary.

    To fix the issue on your side, I suggest you try an explicit conversion like this: (LINECALLBACK)lineCallbackFunc. Or please use DWORD_PTR instead of DWORD as you have posted.

    Best regards,
    Helen Zhao


    Helen Zhao [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Helen Zhao Monday, March 19, 2012 4:43 AM
    Wednesday, March 14, 2012 6:51 AM

All replies

  • IS lineInitializeExA a 32 - bits function that call TAPI32.DLL ?

    Could you give more informations about lineCallbackFunc ?


    Delphine GARRO


    Monday, March 12, 2012 12:42 PM
  • Thanks for your reply Gargo.

    After changing the datatype for 3 to 6 arguments of lineCallbackFunc as DWORD_PTR the error went off.

    • Proposed as answer by Helen Zhao Wednesday, March 14, 2012 6:51 AM
    • Marked as answer by Helen Zhao Monday, March 19, 2012 4:43 AM
    Monday, March 12, 2012 1:08 PM
  • You can try:

    rc = ::lineInitializeExA(&hApp, ::GetModuleHandle(0), (LINECALLBACK)lineCallbackFunc, "", &nDevices, &version, &init);




    • Edited by Bordon Monday, March 12, 2012 1:13 PM
    • Proposed as answer by Helen Zhao Wednesday, March 14, 2012 6:51 AM
    • Marked as answer by Helen Zhao Monday, March 19, 2012 4:43 AM
    Monday, March 12, 2012 1:12 PM
  • I think that you have to change the type of last four arguments of lineCallbackFunc  to DWORD_PTR.


    Monday, March 12, 2012 1:30 PM
  • VOID CALLBACK lineCallbackFunc(DWORD hDevice, DWORD dwMsg, DWORD dwCallbackInstance, DWORD dwParam1, DWORD dwParam2, DWORD dwParam3 ) 

    This looks like the definition from the Windows Mobile 6 TAPI header. You want the Win32 TAPI header:

    typedef void (CALLBACK * LINECALLBACK)(
        DWORD               hDevice,
        DWORD               dwMessage,
        DWORD_PTR           dwInstance,
        DWORD_PTR           dwParam1,
        DWORD_PTR           dwParam2,
        DWORD_PTR           dwParam3
        );

    The DWORD is only unsigned long (32-bit) whereas the DWORD_PTR is unsigned __int64 (64-bit). 

    -PaulH

    • Proposed as answer by Helen Zhao Wednesday, March 14, 2012 6:44 AM
    • Marked as answer by Helen Zhao Monday, March 19, 2012 4:43 AM
    Monday, March 12, 2012 7:09 PM
  • looks like the callback is __stdcall and your function is declared __cdecl (which is the default).

    check your declaration of lineCallbackFunc and make sure it has a __stdcall or CALLBACK attribute.

      void CALLBACK lineCallbackFunc( ...


    Monday, March 12, 2012 7:49 PM
  • Hi rmgs123,

    According to the document in MSDN Library, the third parameter of lineInitializeEx function is of LINECALLBACK type. If you want to know more information about this function, please refer to this link: http://msdn.microsoft.com/en-us/library/ms735983.aspx. Based on the codes you posted, I found that lineCallbackFunc is a callback function.

    Generally speaking, we have the following two ways to resolve C2664:
    1->Recheck the prototype for the given function and correct the argument noted in the error message.
     2->Supply an explicit conversion if necessary.

    To fix the issue on your side, I suggest you try an explicit conversion like this: (LINECALLBACK)lineCallbackFunc. Or please use DWORD_PTR instead of DWORD as you have posted.

    Best regards,
    Helen Zhao


    Helen Zhao [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Helen Zhao Monday, March 19, 2012 4:43 AM
    Wednesday, March 14, 2012 6:51 AM