Re: Connecting to a signal given as a string
- From: Chris Vine <chris cvine freeserve co uk>
- To: Hubert Figuiere <hub figuiere net>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: Connecting to a signal given as a string
- Date: Sun, 26 Oct 2008 17:47:08 +0000
On Sun, 26 Oct 2008 11:51:51 -0400
Hubert Figuiere <hub figuiere net> wrote:
>
> On Sun, 2008-10-26 at 13:11 +0000, Chris Vine wrote:
> > Either your object whose 'this' pointer you passed in no longer
> > exists when the callback is executed, or your on_load_finished()
> > method is defective in some way. What does the debugger show?
> >
> > Actually there is another issue, which will not bite if you are
> > using gcc, namely that your on_page_loaded() function will have C++
> > linkage. It is better to declare it extern "C". which means you
> > then need to put
> > it in anonymous namespace in order for it not to be exported.
> > Something
> > like:
> >
> > namespace {
> > extern "C" {
> > void on_page_loaded (WebView *web_view)
> > {
> > web_view->on_load_finished ();
> > }
> > } // extern "C"
> > } // anonymous namespace
>
> extern "C" is useless here because there is no linkage here. The only
> thing extern "C" does is to change the symbol mangling and forbid
> overloading to be able to call functions from C code (whose reference
> will be resolved at link time).
You are wrong.
It not just about name mangling - different calling conventions may be
employed between C and C++ functions. Functions with C linkage are
obliged to pass arguments on the stack, whereas C++ compilers can
optimise in ways not permitted to functions with C linkage. The C++
standard is quite clear that functions with C and C++ linkage are
different types even if the signatures are the same.
I suggest you read section 9.2.5 of TC++PL. This is also helpful:
https://developers.sun.com/solaris/articles/mixing.html#pfn
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]