c - Porting callback function from 32 bit to 64 bit -
I am using Visual Studio 2008 Professional when I compile it using Win32 Build, it's OK.
But when I switch to x64 I get this compilation error:
Error C2664: 'lineInitializeExA': can not be changed from parameter 3 to 'zero' The goal of 'LINECALLBACK' from (__cdecl *) (DeWords, Dedworlds, Dedworlds, Dedworlds, Dedworlds, DWORD) 'targets any of these types of work does not match the target type. Some are defined / typed:
typedef unsigned Bay DWORD; #define callback __stdcall and the LINECALLBACK in tapi.h is defined as:
typedef zero (callback * LINECALLBACK) (DWORD hDevice, DWORD DwMessage, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2, DWORD_PTR dwParam3); Signing on Windows is 32 bit wide on 32 and 64 bit platforms long. So definitely this is not a problem.
Any ideas why? And how to decide?
Here is the code.
#include & lt; Tapi.h & gt; // Include Windows Tally API # & lt; Stdio.h & gt; / * I know that this Tally 32.Lib is called, but I believe it is just an old naming - 32 bit does not look specific and in any case the step * / #pragma does not get to add a comment ( Lib, "tapi32.lib") zero callback my_callback (DWORD dwDevice, DWORD nMsg, DWORD dwCallbackInstance, DWORD dwParam1, DWORD dwParam2, DWORD dwParam3) {printf ("my_callback" is called \ n "); } Int main () {long result = -1; DWORD dwAPIInit = 0x00020002; HLINEAPP happiness; // Application handle DWORD numbers; // The number of line devices in the system. Results = line initialX (& happiness, GetModuleHandle (0), my_callback, "TAPITEST", and numbers, & amp; dwAPIInit, 0); Return 0; } **** Edit. Not sure why, but I was looking at DWORD_PTR:
typedef unsigned long DWORD_PTR; but being used on the probe:
typedef ULONG_PTR DWORD_PTR, * PDWORD_PTR; So the definition of my callback is wrong! Logic 'announcements in context of
zero (callback * LINECALLBACK) (DWORD hDevice, DWORD dwMessage, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2, DWORD_PTR dwParam3); is not in this form:
zero callback my_callback (DWORD dwDevice, DWORD nMsg, DWORD dwCallbackInstance, DWORD dwParam1, DWORD dwParam2, DWORD dwParam3) : The logic 3 to 6 are symbols in the integer in the second and the second.
All 32-bit Windows as the DWORD s is the same size as the indicator, it can be compiled. Although Windows 64bits- on the indicator has a different size than DWORD s.
Comments
Post a Comment