Thread: Calling class function from stdcall ?

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    1

    Calling class function from stdcall ?

    I am quite new to c++ so please bear with me.

    I have an Adlink Angelo RTV24 video capture card, and to grab the images I need to use their c++ library.

    This function is an event callback from the card
    Code:
    AngeloRTV_Set_Callback(1, MediaStreamProc);
    The event callback function looks like this
    Code:
    void __stdcall MediaStreamProc(){
     // remove for space
    }
    I am using their functions within my own class 'angeloWrapper'

    However, the MediaStreamProc function can't access any data/functions from my wrapper, as this is part of stdcall and not angeloWrapper.

    So, how can I call a function from my wrapper from within the stdcall event function? I've tried calling...
    Code:
    test(); // identifier not found
    angeloWrapper::test(); // illegal call of non-static member function
    Any ideas? Many thanks

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You can't use C++ functions directly as call-back functions. If the callback allows an arbitrary pointer type argument, then you can use that and cast it from & to the class pointer as needed.

    It actually isn't really to do with __stdcall, although a class-method uses the calling convention called "thiscall" because there is a hidden argument "this", representing the object itself.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I'm not quite sure what or how you're doing this. Care to elaborate a little?
    Are you trying to call a class method (directly) from within the wrapper???

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. call base class function or derived class function
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 03-18-2008, 05:23 AM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  3. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM
  4. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM