Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Incompatible pointer to integer conversion ...
Forum Updated to NodeBB v4.3 + New Features

Incompatible pointer to integer conversion ...

Scheduled Pinned Locked Moved Unsolved C++ Gurus
2 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • RogerBretonR Offline
    RogerBretonR Offline
    RogerBreton
    wrote on last edited by
    #1

    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?

    Roger Breton
    www.graxx.ca

    jeremy_kJ 1 Reply Last reply
    0
    • RogerBretonR RogerBreton

      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?

      jeremy_kJ Offline
      jeremy_kJ Offline
      jeremy_k
      wrote on last edited by
      #2

      @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) ?

      Asking a question about code? http://eel.is/iso-c++/testcase/

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved