[sigc] newbie questions



Hi.  I'm not new to C++, but I am new to libsigc++.  I'm finding it difficult to navigate the documentation and examples.

I'm running Fedora Core 4 with these installed:

  libsigc++20-2.0.11-1
  libsigc++20-devel-2.0.11-1

Googling "libsigc++" turns up:

  http://libsigc.sourceforge.net/

The reference documentation doesn't seem to include examples, so I tried "tutorial-style".  Tho motivation section is quite motivating!

However, I hit snags at the Alien example.  It does give the command line for compiling, but the example code given up to that point does not compile: doesn't say what to #include, missing definitions for AlienDetector::run(), AlienDetector::AlienDetector().  I also don't see any links to downloadable, runnable examples.  At this point, I'm pretty much dead in the water.  Is getting started easier for other people?  Am I overlooking some obvious documentation or examples or tutorials?

So at this point, I gave up and decided to take a stab at what I had in mind, grabbing bits and pieces from various places on the web.   I have:

----------------------------------------------
$cat hello.cc

#include <iostream>

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

using namespace std;

void hello() { cout<<"hello, "<<flush; }
void world() { cout<<"world!"<<endl; }

int main()
{
   SigC::Signal0<void> signal;

   signal.connect(SigC::slot(hello));
   signal.connect(SigC::slot(world));

   signal.emit();

   cout<<"Good night, Moon."<<endl;
}

----------------------------------------

compiled with:

$ cat Makefile

default: hello
        ./hello


hello: hello.cc
        g++ hello.cc -o hello `pkg-config --cflags --libs sigc++-2.0`

clean:
        -rm -f *.o hello

------------------------------------------
giving this output:

$ make
g++ hello.cc -o hello `pkg-config --cflags --libs sigc++-2.0`
./hello
hello, world!
Good night, Moon.
make: *** [default] Segmentation fault

------------------------------------------

Questions:
  1) Have I done something exceptionally goofy or not in the spirit of libsigc++?
  2) Why does the tutorial give the namespace "sigc", but I have to use "SigC"?
  3) Why does sigc++/sigc++.h #include sigc++/signal.h, but not sigc++/slot.h?
  4) Why the segfault?

Thanks in advance for any help.

Greg





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]