Sign in to follow this  

Callback library

This topic is 4199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm writing a GUI system, and I need a good C++ callback library to implement event-handling. I already tried using libsigc++ v2.0.17, but my test programs crash (SIGSEGV inside STL, when calling sigc::signal.connect ()). I downgraded to libsigc+++ v2.0.0, and the same thing happened. Now I'm looking for another C++ callback library. Type safety is required. Any suggestions?

Share this post


Link to post
Share on other sites
Okay, could you atleast help me with libsigc++?
Here's my test program:


#include <sigc++/sigc++.h>
#include <iostream>

using namespace std;

static void handler1 (char *s)
{
cout << "1) " << s << endl;
}

static void handler2 (char *s)
{
cout << "2) " << s << endl;
}

int
main (void)
{
sigc::signal<void,char*> mysig;

mysig.connect (ptr_fun (&handler1));
mysig.connect (ptr_fun (&handler2));

mysig.emit ("foo");
mysig.emit ("bar");

exit (0);
}


It dies like this:

Starting program: C:\Dev-Cpp\Projects\phgui\test/test-sigc.exe

Program received signal SIGSEGV, Segmentation fault.
0x10003499 in std::_List_node_base::hook(std::_List_node_base*) ()
Current language: auto; currently c++
(gdb) bt
#0 0x10003499 in std::_List_node_base::hook(std::_List_node_base*) ()
#1 0x10039924 in std::list<sigc::slot_base, std::allocator<sigc::slot_base> >::
insert(std::_List_iterator<sigc::slot_base>, sigc::slot_base const&) (
this=0x18, __position={_M_node = 0x18}, __x=@0x23ff58)
at C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/
list.tcc:88
#2 0x10001548 in sigc::internal::signal_impl::insert(std::_List_iterator<sigc::
slot_base>, sigc::slot_base const&) (this=0x10, i={_M_node = 0x18},
slot_=@0x23ff58) at signal_base.cc:64
#3 0x1000158f in sigc::internal::signal_impl::connect(sigc::slot_base const&)
(this=0x10, slot_=@0x23ff58)
at C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/
stl_list.h:615
#4 0x10001770 in sigc::signal_base::connect(sigc::slot_base const&) (
this=0x23fea0, slot_=@0x23ff58) at signal_base.cc:122
#5 0x0041127b in _size_of_stack_reserve__ ()
#6 0x004013d7 in _size_of_stack_reserve__ ()
#7 0x0040116a in _size_of_stack_reserve__ ()
#8 0x00401018 in _size_of_stack_reserve__ ()
#9 0x7c816d4f in _libmsvcrt_a_iname ()

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
What about sigslot?
http://sigslot.sourceforge.net/

Share this post


Link to post
Share on other sites
I'm guessing that libsigc++ is built into a dll, and your own application is in another dll or exe.

Check that you are using the same runtime libraries in both the libsigc++ library and in your application.

Check that you are compiling/linking the libsigc++ library using the same defines as your application.

Share this post


Link to post
Share on other sites
Hmm, tough decision...
To use libsigc++, dig through a dozen of makefiles, mess with cryptic spaghetti "CXXFLAGS" definitions, start losing hair, and finally link my application against a ~700kB DLL, or to simply include a cute ~70kB sigslot.h header?

Share this post


Link to post
Share on other sites

This topic is 4199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this