[fpc-pascal] Migrating MW objects definitions
fpanasiti at tiscali.it
fpanasiti at tiscali.it
Thu Oct 6 19:25:29 CEST 2005
>-- Messaggio Originale --
>From: Jonas Maebe <jonas.maebe at elis.ugent.be>
>Subject: Re: [fpc-pascal] Migrating MW objects definitions
>Date: Thu, 6 Oct 2005 15:01:56 +0200
>To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
>Reply-To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
>
>
>
>On 6 okt 2005, at 14:40, fpanasiti at tiscali.it wrote:
>
>> I'm trying to migrate MW OO code to FPC. I'm in trouble with this
>> piece of
>> MW code:
>>
>> type
>> myObjectA = object
>> .....
>> lObj: myObjectB;
>> ...
>> end;
>>
>> type
>> myObjectB = object
>> ...
>> lObj: myObjectA
>> ...
>> end;
>>
>> Essentially when the compiler tries to deal with myObjectA, it says
>> that
>> 'myObjectB is not defined'.
>>
>> Am I doing something wrong, or is it something not supported by FPC?
>
>You have to use a forward declaration:
>
>type
> MyObjectB = object;
>
> myObjectA = object
> .....
> lObj: myObjectB;
> ...
> end;
>
> myObjectB = object
> ...
> lObj: myObjectA
> ...
> end;
>
>Notes:
>
>a) forward declaration of MacPascal-style objects was not supported
>in our initial implementation due to a bug
>b) the forward declaration and the full declaration of a type must be
>present in the same type-block (which is not the case in your example
>above, even if you would add a forward declaration, since there you
>start a new type-block for each declaration)
>
>
>Jonas
Got the point, but there's still something wrong as I've tried the following
code but the parser claims for an identifier instead ';' at the third line:
(I'm using FPC 2.0.0: could it matter?)
program TestObjects;
type
myObjectB = object;
myObjectA = object
index: longint;
lObj: myObjectB;
procedure SayHello;
end;
myObjectB = object
index: longint;
lObj: myObjectA;
procedure SayHello;
end;
........
francesco
_______________________________________________
>fpc-pascal maillist - fpc-pascal at lists.freepascal.org
>http://lists.freepascal.org/mailman/listinfo/fpc-pascal
__________________________________________________________________
TISCALI ADSL
Solo con Tiscali Adsl navighi senza limiti e telefoni senza canone
Telecom a partire da 19,95 Euro/mese.
Attivala subito, I PRIMI DUE MESI SONO GRATIS! CLICCA QUI:
http://abbonati.tiscali.it/adsl/sa/1e25flat_tc/
More information about the fpc-pascal
mailing list