Re: extern "C", C++, and GTK+ callbacks.
- From: Murray Cumming <murrayc murrayc com>
- To: Ainsley Pereira <gtkmm pebble org uk>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: extern "C", C++, and GTK+ callbacks.
- Date: Fri, 21 Jan 2005 08:36:10 +0100
On Thu, 2005-01-20 at 12:49 +0000, Ainsley Pereira wrote:
> On Thu, Jan 20, 2005 at 11:18:23AM +0100, Murray Cumming wrote:
> > Some compilers [1], correctly complain when we use a static member
> > function as a GTK+ callback. GTK+ expects (and declares) an "extern C"
> > pointer-to-function, but our static member methods are not declared as
> > "extern C".
> >
> > Unfortunately, it seems that static member methods can never be extern
> > "C". g++ does not allow anything like this:
> >
> > class something
> > {
> > public:
> > extern "C" void function_one();
> >
> > extern "C"
> > {
> > void function_one();
> > }
> > }
> >
> A quick test suggests that:
>
> class something
> {
> public:
> static void function_one();
> };
>
> extern "C"
> {
> void something::function_one()
> {
> }
> }
>
> is accepted under gcc (3.3.3, at least - I'm just updating my whole
> system to newer versions now). Does this cause Sun's compiler to accept
> it?
That won't do much good, because the linker will not see the
implementation. I guess that the extern "C" there has no meaning.
--
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]