Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I am very green in Linux. That is why I posted here. The title was too short. I need to write a callback function from a shared library that ...
  1. #1
    Just Joined!
    Join Date
    Dec 2011
    Posts
    1

    How do I write the following callback function?

    Hi,
    I am very green in Linux. That is why I posted here.
    The title was too short.
    I need to write a callback function from a shared library that will call to a function that is inside the executable.
    I am too green to linux, that I am not even share if Linux uses *.exe files ><
    Any, I will try to explain what I am trying to do here:
    Code:
    //Executable
    
    void functionA()
    {
    //code that calls to functions inside EXE
    }
     
    void functionB()
    {
    //code that calls to functions inside EXE
    }
     
    void functionC()
    {
    //code that calls to functions inside the Executable
    }
     
    //Shared Library
    void functionSL()
    {
    // I need to call functionA(), functionB() & functionC()
    }
    So, instead of writing three callback functions.
    I did the following:

    Code:
    //Executable
    void functionABC()
    {
    functionA();
    functionB();
    functionC();
    }
     
    //Shared library
    //Must call functionABC()
    Therefore, unfortunately, even if I would create a shared library, and place functionA(), functionB() functionC() inside it, I will still have create Callback functions for the functions that are called from within functionA/B/C() ><

    Furthermore, this is not my code. I am trying to add some simple functionality there. I did it on windows, and now I need to test it on Linux. But, I can't seem to get the right syntax for callback functions there.

    Any ideas on "Callback functions to a function that is inside an executable?"
    Thanx!

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,970
    One method would be to have a global variable that is a function pointer which is either initialized to null, or a stub function. The executable would set the pointer to a valid function of its own, then the shared library can call the function that the executable has "registered" with the global variable. This is not an uncommon technique, and one I have used in the past.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...