By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,742 Members | 1,044 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,742 IT Pros & Developers. It's quick & easy.

multiple callbacks per function pointer / event

P: n/a
Hi I was wondering if anyone knows of a method to achieve the creation of
events in c. currently I use a function pointer to call one callback.
However, I really need to map the function pointer or event to multiple
callback functions.

I thought I would have functions like NewSignal, EmitSignal and
ConnectSignal but I don't know how I would construct function pointers at
any other time other than compile time. Each new signal would require a
function pointer that takes different arguments, how would you marshall
data to these different function pointers?

I know there are toolkits like GTK that provide this but I am stuck using
Labwindows which provides very little and didn't want systems that provide
their own event loops etc.

Any help it much appreciated.
Thanks

Glenn

Nov 14 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
glennpierce wrote:
Hi I was wondering if anyone knows of a method to achieve the creation of
events in c. currently I use a function pointer to call one callback.
However, I really need to map the function pointer or event to multiple
callback functions.
Build a linked list or array of them.
I thought I would have functions like NewSignal, EmitSignal and
ConnectSignal but I don't know how I would construct function pointers at
any other time other than compile time. Each new signal would require a
function pointer that takes different arguments, how would you marshall
data to these different function pointers?
Yes, you will need different types for different functions. You might get
away with another level of indirection, using a function that knows the
real type and marshals arguments there and returnvalues back. Another tool
that might help is some macros. <heresy> There are several C++ libs that
do this in a type-safe, generic way.</heresy>
I know there are toolkits like GTK that provide this but I am stuck using
Labwindows which provides very little and didn't want systems that
provide their own event loops etc.


GTK is free software, you are even free to only use parts of it, provided
you accept its license.

Uli
Nov 14 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.