[fpc-pascal] Compile error with published field

Joao Morais post at joaomorais.com.br
Sat Nov 18 16:31:35 CET 2006

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)

Joao Morais

More information about the fpc-pascal mailing list