LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-30-2011, 11:42 PM   #1
coffeenet
LQ Newbie
 
Registered: Dec 2011
Posts: 2

Rep: Reputation: Disabled
Question 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!
 
Old 01-02-2012, 08:49 PM   #2
cvt
Member
 
Registered: Jul 2004
Location: UK
Distribution: Slackware
Posts: 37

Rep: Reputation: 17
Without having tried it myself recently (so not sure how helpful this is gonna be to you), but functions or normally available on the stack?, so you should be able to pass the function addresses round.

After a bit of a google I did run accross this little gem....
http://tigcc.ticalc.org/doc/gnuexts.html#SEC66

It discusses nested functions and the passing of function addresses. This is for C though. You neglected to mention which language you were using.
 
Old 01-03-2012, 12:15 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Nothing special.

Main code:

Code:
extern void funSlib (void);
void funExe (void)
{... funSlib (); ...}
shared lib

Code:
extern void funExe (void);
void funSlib (void)
{... funExe (); ...}

Last edited by NevemTeve; 01-03-2012 at 12:17 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
what is callback function context? manohar Programming 1 03-18-2011 01:05 PM
Why does the callback function go BEFORE the send() in AJAX? resetreset Programming 1 01-27-2011 06:02 AM
glib-object get return value from a signal in the callback function joel2001k Programming 1 02-09-2009 12:57 AM
how does function callback works ?? alred Programming 5 05-12-2006 01:07 AM
setTimeObject CallBack time function branens Programming 0 02-16-2005 04:30 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration