Am Sonntag, den 18.05.2008, 22:51 +0200 schrieb Graeme Geldenhuys: > 2008/5/18 Marc Santhoff <[EMAIL PROTECTED]>: > > When using a cast from an interface to an object the compiler warns > > about the class types "TObject" and "IObserver" not being related. > > > > Since an implementor of in interface always will be a class type and any > > class type at least inherits from TObject, I assume it is okay? > > > > Is there a better method of handling this case? > > Casting of Interfaces has always been known to me as a big NO-NO.
I learned casting in general is sort of evil, but not always avoidable. > I > believe it's got something to do with how they are represented in the > VMT or method table or something like that. I don't know the compiler > internals. I see, enough to remember "Do not cast interfaces!". ;) > Why not simply use a InterfaceList or a generic Pointer > list (as to not increment the interface reference counter). You can > then add them to the list without having to cast to TObject. That's what I will do. Thank you, Marc _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal