Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Callback functions

Callback functions

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
4 Posts 2 Posters 0 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.
  • W Offline
    W Offline
    will1383
    wrote on last edited by
    #1

    hi All, I have a class with functions and I'm calling into a dll with a function that specifies a callback function Here's the function I'm calling: extern "C" __declspec(dllexport) void stuffFunction(void (*UpdateCallback)(int iLoad)) And here's the class function I'm trying to pass in as a call back: void CSomeClass::UpdateCallback(int iLoad); I get the error: error C2664: 'someapp.c' : cannot convert parameter 1 from 'void (int)' to 'void (__cdecl *)(int)' If I declare the UpdateCallback to be a static function, it builds with no errors. I need to have access to the class members so I can't declare it as a static function. Any ideas? Thanks in advance!

    R 1 Reply Last reply
    0
    • W will1383

      hi All, I have a class with functions and I'm calling into a dll with a function that specifies a callback function Here's the function I'm calling: extern "C" __declspec(dllexport) void stuffFunction(void (*UpdateCallback)(int iLoad)) And here's the class function I'm trying to pass in as a call back: void CSomeClass::UpdateCallback(int iLoad); I get the error: error C2664: 'someapp.c' : cannot convert parameter 1 from 'void (int)' to 'void (__cdecl *)(int)' If I declare the UpdateCallback to be a static function, it builds with no errors. I need to have access to the class members so I can't declare it as a static function. Any ideas? Thanks in advance!

      R Offline
      R Offline
      Rickard Andersson20
      wrote on last edited by
      #2

      What you are doing is illegal. You can't use a method as you do. You'll need to make it static. Non-static methods can only be accesed by an instance of the class. So, you need to make it static. Rickard Andersson8 Here is my card, contact me later! UIN: 50302279 E-Mail: nikado@pc.nu Interests: C++, ADO, SQL, Winsock, 0s and 1s

      W 1 Reply Last reply
      0
      • R Rickard Andersson20

        What you are doing is illegal. You can't use a method as you do. You'll need to make it static. Non-static methods can only be accesed by an instance of the class. So, you need to make it static. Rickard Andersson8 Here is my card, contact me later! UIN: 50302279 E-Mail: nikado@pc.nu Interests: C++, ADO, SQL, Winsock, 0s and 1s

        W Offline
        W Offline
        will1383
        wrote on last edited by
        #3

        That's what I thought :( I just wanted to be sure there were no other tricks out there I didn't know about. Thanks.. .... Just gotta do it another way =)

        R 1 Reply Last reply
        0
        • W will1383

          That's what I thought :( I just wanted to be sure there were no other tricks out there I didn't know about. Thanks.. .... Just gotta do it another way =)

          R Offline
          R Offline
          Rickard Andersson20
          wrote on last edited by
          #4

          will1383 wrote: I just wanted to be sure there were no other tricks out there I didn't know about. Yeah! It's better being on the safe side! :) Rickard Andersson8 Here is my card, contact me later! UIN: 50302279 E-Mail: nikado@pc.nu Interests: C++, ADO, SQL, Winsock, 0s and 1s

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups