[fpc-pascal] Compile error with published field

Michael Van Canneyt michael at freepascal.org
Sun Nov 19 00:31:25 CET 2006



On Sat, 18 Nov 2006, Joao Morais wrote:

> Michael Van Canneyt wrote:
> 
> > > > This is the code:
> > > >
> > > >   TPressObject = class(TPressSubject)
> > > >     _Id: TPressString;
> > > >   private  // <- compiler stops here
> > > >     ...
> > > >
> > > > and this is the inheritance:
> > > >
> > > > TPersistent (Classes unit)
> > > > +-TPressStreamable (PressClasses unit)
> > > >   +-TPressSubject (PressSubject unit)
> > > >      +-TPressObject (PressSubject unit)
> > > >      +-TPressAttribute (PressSubject unit)
> > > >        +-TPressString (PressSubject unit)
> > > >
> > > > I also tried to move the member to the published area; declared the
> > > > class
> > > > under the $M+ directive; but no success. Moving the _Id member to the
> > > > private area solves the compilation problem.
> > > The problem is - TPressString is a forward declaration and the compiler
> > > doesn't know that it inherits from TPersistent. Is this the expected
> > > behavior?
> > 
> > Yes. The compiler has no idea that _Id is publishable, and therefor rejects
> > it.
> 
> Thanks Michael.
> 
> But is this the correct behavior, a non implemented feature or a bug? (note -
> Delphi doesn't raise this error)

As far as I'm concerned it's correct behaviour, but you'll have to ask the compiler
gurus for confirmation :-)

Michael.



More information about the fpc-pascal mailing list