Skip to main content
GameDev.net gamedev.net
🔒 Locked

Callback library

Started by phraine Jun 14, 2006 at 9:03 AM 5 replies 1.4k views
Original Post
phraine
phraine
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?
phraine
phraine
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;}intmain (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.exeProgram 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 ()
Nitage
Nitage
Have you looked at boost signals?
dalleboy
dalleboy
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.
phraine
phraine
sigslot seems cool!
And I just downloaded the whole boost library... Damn!
phraine
phraine
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?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.