Re: Using a macro, can I change what type an object is being cast to?
From: Karl Heinz Buchegger (kbuchegg_at_gascad.at)
Date: 03/16/05
- Next message: Martin T.: "Windows Compiler with format-string warning option ?"
- Previous message: lallous: "Re: mobile phone keyboard"
- In reply to: Eric Lilja: "Using a macro, can I change what type an object is being cast to?"
- Next in thread: Eric Lilja: "Re: Using a macro, can I change what type an object is being cast to?"
- Reply: Eric Lilja: "Re: Using a macro, can I change what type an object is being cast to?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 16 Mar 2005 21:29:52 +0100
Eric Lilja wrote:
>
> So why do I want to do this? Well, as I said I am trying to encapsulate a
> third-party C-based gui toolkit that revolves around callbacks. My parent
> class has a static member function that acts a dummy callback (called by the
> system), and using the parameters it finds a pointer to itself (actually a
> pointer to a subclass) and uses that to call non-static member functions.
> The problem is that the system seems to be calling this static member
> function before the subclass object has been constructed fully thus calling
> the parent version of some virtual functions the first few calls.
And you think, that casting the pointer will help with that?
If the object isn't fully constructed, the most likely thing is
that you produce a crash (if you are lucky). If you are unlucky
the system just executes whatever it finds in memory, thinking
this is your function.
Why not install the callback *after* the object has been constructed
fully. That would avoid all those problems.
-- Karl Heinz Buchegger kbuchegg@gascad.at
- Next message: Martin T.: "Windows Compiler with format-string warning option ?"
- Previous message: lallous: "Re: mobile phone keyboard"
- In reply to: Eric Lilja: "Using a macro, can I change what type an object is being cast to?"
- Next in thread: Eric Lilja: "Re: Using a macro, can I change what type an object is being cast to?"
- Reply: Eric Lilja: "Re: Using a macro, can I change what type an object is being cast to?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|