[fpc-devel] Re: Illegal type conversion: "<enumeration type>" to "TObject"

Schatzl Thomas tom_at_work at gmx.at
Fri Jul 18 12:35:09 CEST 2008


Hello,

> Date: Fri, 18 Jul 2008 10:31:01 +0200 (CEST)
> From: marcov at stack.nl (Marco van de Voort)
> > On Thu, 17 Jul 2008, Florian Klaempfl wrote:
> > > > 
> > > > type
> > > > TEnum = (a, b, c);
> > > > var
> > > >  AValue: TEnum;
> > > >  AObject : TObject;
> > > > implementation
> > > > 
> > > > initialization
> > > >  AObject := TObject(AValue);
> > > > Could this be supported in the Delphi mode as well?
> > > 
> > > Please submit a bug report.
> > 
> > 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.

Regards,
  Thomas


-- 
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten 
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser



More information about the fpc-devel mailing list