Re: extern "C", C++, and GTK+ callbacks.



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?

~A.



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