[fpc-devel] Re: Illegal type conversion: "<enumeration type>" to "TObject"
Marco van de Voort
marcov at stack.nl
Fri Jul 18 12:38:20 CEST 2008
> > Date: Fri, 18 Jul 2008 10:31:01 +0200 (CEST)
> > >
> > > Eh ?
> > > As far as I'm concerned this should not compile in Objfpc mode as well ?
> >
> > It should compile if sizeof(tenum)=sizeof(tobject) else not? So probably
> > also in Delphi this code depends on $Z ($minenum)
>
> This will never compile directly on 64 bit platforms (x64/ppc64) because afaik sizeof(enum) always <> sizeof(tobject) there. The original poster didn't mention his platform afaik.
>
> Maybe use "AObject := TObject(PtrUInt(AValue));".
>
> Minenumsize is not a solution, since the allowed values are only 1,2 or 4 according to the docs.
It was not meant as a solution, but as a clarification of the behaviour, and
to show that in some cases it can work, depending on $Z.
More information about the fpc-devel
mailing list