[fpc-pascal] Why casting interface as Tobject will result in a different reference?

Ryan Joseph ryan at thealchemistguild.com
Fri May 26 11:11:47 CEST 2017


> On May 26, 2017, at 4:06 PM, Dennis <dec12 at avidsoft.com.hk> wrote:
> 
>  writeln(  IntToHex(LongWord(aInt),4));
> 
>  writeln(  IntToHex(LongWord(aObj),4)); //this will output a different Hex value from previous writeln

I think an object and interface are indeed not the same memory and you need to use Supports() to get a reference to the interface from the object. The interface reference can be cached and used later or you need to call Supports every time which does a string compare and is slow.

Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list