Incompatible pointer to integer conversion ...
-
I have a DLL which I can access successfully in a Console application from MS Visual C++.
I would like to replicate that 'exploit' using QT Creator instead -- why not?
Problem is, QT is unable to find the functions inside the DLL.
So I'm exploring "Explicit linking" instead.
So far, so good.I'm using : QLibrary myLib("DEVICE.dll");
Then : LoadResult = myLib.load();Then I declare a function pointer this way, exactly as defined in the DEVICE.h :
typedef int (*RegisterEventHandler)(const FPtr_DEVICE_DeviceEventHandler inHandler);
There is one important function in that DLL which creates an Event Handler (to communicate with the Device) which :
RegisterEventHandler FnAddress = (RegisterEventHandler) myLib.resolve("DEVICE_RegisterDeviceEventHandler");
I then have to call that function, which returns some kind of (int) Error code :
deviceError = RegisterEventHandler(EventNotice);
The Event Notice function contains all the code to process the data returned by the device and looks like this :
void EventNotice(Device_EventCode outEventCode, uint32 outRAWDataCount, DEVICE_ERROR_TYPES outError);
It contains a simple switch statement with a bunch of cases, to process the code returned by the handler (not shown).
The problem is, the compiler complains with this :
C:\Users\roger\Documents\Console\main.cpp:64: error: incompatible pointer to integer conversion assigning to 'DEVICE_ERROR_TYPES' from 'RegisterEventHandler' (aka 'int (*)(void (*const)(DEVICE_EventCode, unsigned int, DEVICE_ERROR_TYPES))')
I confess I'm relatively new to c++ and would appreciate some help with regards to this error.
The examples for this kind of error I found on various Forums did not help? -
@RogerBreton said in Incompatible pointer to integer conversion ...:
I have a DLL which I can access successfully in a Console application from MS Visual C++.
I would like to replicate that 'exploit' using QT Creator instead -- why not?
Problem is, QT is unable to find the functions inside the DLL.If you are attempting to use the function via the regular dynamic loading mechanism, neither Qt nor Creator is involved in locating a function within the dll. Are you certain that the dll file is in the right location, and that the linker options used by the successful console application are applied to the unsuccessful one?
So I'm exploring "Explicit linking" instead.
...
typedef int (*RegisterEventHandler)(const FPtr_DEVICE_DeviceEventHandler inHandler);
[...]
RegisterEventHandler FnAddress = (RegisterEventHandler) myLib.resolve("DEVICE_RegisterDeviceEventHandler");
[...]
deviceError = RegisterEventHandler(EventNotice);It's hard to read the intermixed C++ and English, but it looks like this is attempting to use the function pointer typedef as the function pointer. Should this be
deviceError = FnAddress(EventNotice)
?