[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dynamic_cast problem
From: |
Rolf Magnus |
Subject: |
Re: dynamic_cast problem |
Date: |
Sun, 04 Jul 2004 11:08:37 +0200 |
Ulrich Eckhardt wrote:
> KeithO wrote:
>> extern "C" DestinationImpl * getDestinationImpl(void);
>
>> MODULE_HANDLE fn = (void *(*)())dlsym(hdll,
>> "getDestinationImpl");
>
> The functiontypes don't match. Further, I'd use a typedef(at least for
> your readers).
He does use a typedef, but for some reason, he doesn't use it for the
cast, but only for defining fn.
> Also consider that this cast is not valid, neither in C
> nor C++. Take a look at comp.lang.c++.moderated, there was a thread
> started by me that explains the details.
I don't think you can use a valid cast in this place at all. That's just
a problem with dlsym.
> BTW: why pass around a void*? Your lib could as well declare the
> struct class and export a function returning a pointer to it.
That's what the lib is actually doing. The OP is just interpreting that
pointer as a void* in the main program and then converting that "back"
into a DestinationImpl*.