This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

problems passing subclass methods as function pointer parameters


Hi,

I'm having some difficulty in getting code that works great with version 
2.96 to compile with version 3.0. I'm using g++ on RedHat Linux with a 2.2 
kernel. I posted here before and got no response, so I've tried to rephrase 
and clarify the issue below.

Specifically, the compiler will no longer allow passing of methods of a 
subclass where a the function pointer prototype specifies a method of the 
superclass. So, for a typedef FOO of the form

  typedef void (SUPERCLASS::*FOO)(void);

I can not pass methods of class SUBCLASS (where SUBCLASS is a public 
subclass of  SUPERCLASS) to functions requiring a parameter of type FOO.

More specifics below; the only options of note are -g2 and -W, and the 
exact compiler message is:

GsForwardThread.cpp:247: no matches converting function `handle_SMsg_Ping' to
    type `void (class LmThread::*)(class LmSrvMesgBuf*, class LmConnection*)'
GsForwardThread.h:50: candidates are: void
    GsForwardThread::handle_SMsg_Ping(LmSrvMesgBuf*, LmConnection*)

* note: GsForwardThread is a public subclass of LmThread

where the offensive line is

RegisterHandler(mtype, (MsgHandler)&(GsForwardThread::handle_SMsg_Ping)))

and the (method pointer) type MsgHandler is

  typedef void (LmThread::*MsgHandler)(LmSrvMesgBuf* msgbuf, LmConnection* 
conn);

Any thoughts on what to try to get this to compile? It seems every time I 
upgrade gcc, the method parameter passing breaks...

thanks so much!

Brent


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]