Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-10

Migrating MW objects definitions

17 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

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?

Francesco

__________________________________________________________________ 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/

Peter Vreman
to Unknown author
Show quoted text 21 lines
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?

If it works with MW, but fails with FPC it is not supported. Please log it as a bug with a short example.

Jonas Maebe
to Unknown author: I'm trying to migrate MW OO code to FPC. I'm in trouble with this piece of MW code: type…
Show quoted text 23 lines
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

Ivan Shikhalev
to Jonas Maebe

-----Original Message-----
From: Jonas Maebe

You have to use a forward declaration:

[skip]

AFAIK, this is impossible for static objects (object-types) as record-types too. It is needed to use class-types or pointers to object-types.

Jonas Maebe
to Ivan Shikhalev
Ivan Shikhalev wrote 7 lines
> You have to use a forward declaration: [skip] AFAIK, this is impossible for static objects (object-types) as record-types too. It is needed to use class-types or pointers to object-types.

We are talking about MacPas mode. MacPas objects are similar to classes in Delphi and are just pointers internally.

Jonas

Unknown author
to Jonas Maebe: You have to use a forward declaration: type MyObjectB = object; myObjectA = object .....…
Show quoted text 63 lines
-- Messaggio Originale -- From: Jonas Maebe Subject: Re: [fpc-pascal] Migrating MW objects definitions Date: Thu, 6 Oct 2005 15:01:56 +0200 To: FPC-Pascal users discussions Reply-To: FPC-Pascal users discussions On 6 okt 2005, at 14:40, 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

Jonas Maebe
to Unknown author
Show quoted text 5 lines
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?)

Yes, support for MacPas style objects is only implemented in 2.1.x

Jonas

Unknown author
to Jonas Maebe
Show quoted text 22 lines
-- Messaggio Originale -- From: Jonas Maebe Subject: Re: [fpc-pascal] Migrating MW objects definitions Date: Thu, 6 Oct 2005 19:28:07 +0200 To: FPC-Pascal users discussions Reply-To: FPC-Pascal users discussions On 6 okt 2005, at 19:25, wrote: > 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?) Yes, support for MacPas style objects is only implemented in 2.1.x Jonas

I tried the 2.1.1 but it doesn't work yet, even I get different error messages (i.e. 'duplicate identifier myObjectB' and 'forward type not resolved myObjectB').

Francesco

__________________________________________________________________ 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/

Jonas Maebe
to Unknown author
I tried the 2.1.1 but it doesn't work yet, even I get different error messages (i.e. 'duplicate identifier myObjectB' and 'forward type not resolved myObjectB').

If you downloaded a snapshot, the reason is probably that it was added after that snapshot was created.

Jonas

Lee, John

FYI the latest Win32 v2.1.1 snapshot on ftp freepascal.org was last night & contains all source changes up to then. John

Show quoted text 5 lines
If you downloaded a snapshot, the reason is probably that it was added after that snapshot was created.

This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.

Jonas Maebe
to Lee, John
John wrote
FYI the latest Win32 v2.1.1 snapshot on ftp freepascal.org was last night & contains all source changes up to then. John

That does not help for people using Mac OS X (which is where most MacPas users are).

Jonas

Lee, John

Mmm agree... wasn't very helpful! J

Show quoted text 25 lines
-----Original Message----- From: Behalf Of Jonas Maebe Sent: 07 October 2005 14:05 To: FPC-Pascal users discussions Subject: Re: [fpc-pascal] Migrating MW objects definitions On 7 okt 2005, at 14:58, Lee, John wrote: > FYI the latest Win32 v2.1.1 snapshot on ftp freepascal.org was last > night & contains all source changes up to then. John That does not help for people using Mac OS X (which is where most MacPas users are). Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.

Unknown author
to Jonas Maebe: If you downloaded a snapshot, the reason is probably that it was added after that…
Show quoted text 21 lines
-- Messaggio Originale -- From: Jonas Maebe Subject: Re: [fpc-pascal] Migrating MW objects definitions Date: Fri, 7 Oct 2005 14:49:07 +0200 To: FPC-Pascal users discussions Reply-To: FPC-Pascal users discussions On 7 okt 2005, at 14:23, wrote: > I tried the 2.1.1 but it doesn't work yet, even I get different > error messages > (i.e. 'duplicate identifier myObjectB' and 'forward type not > resolved myObjectB'). If you downloaded a snapshot, the reason is probably that it was added after that snapshot was created. Jonas

I've downloaded the latest shapshots available on the web page (both June and July version). Something which could matter: I couldn't use the standard installer (aborted trying to install something called 'very big app'), thus I inflated the archive + copy the contents using the terminal command lines. Maybe something was missed that way round?
Francesco

_______________________________________________ fpc-pascal maillist - 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/

Vincent Snijders
to Jonas Maebe: If you downloaded a snapshot, the reason is probably that it was added after that…
Jonas Maebe wrote 12 lines
On 7 okt 2005, at 14:23, wrote: > I tried the 2.1.1 but it doesn't work yet, even I get different error > messages > (i.e. 'duplicate identifier myObjectB' and 'forward type not resolved > myObjectB'). If you downloaded a snapshot, the reason is probably that it was added after that snapshot was created.

I build fpc 2.1.1 snapshots for lazarus (http://www.lazarus.freepascal.org). You can download them from http://www.de.freepascal.org/lazarus or one of its mirrors.

Warning: the snapshots are not tested before uploading.

Vincent.

Peter Vreman
to Unknown author: I've downloaded the latest shapshots available on the web page (both June and July…
Show quoted text 15 lines
>> I tried the 2.1.1 but it doesn't work yet, even I get different >> error messages >> (i.e. 'duplicate identifier myObjectB' and 'forward type not >> resolved myObjectB'). > >If you downloaded a snapshot, the reason is probably that it was >added after that snapshot was created. I've downloaded the latest shapshots available on the web page (both June and July version). Something which could matter: I couldn't use the standard installer (aborted trying to install something called 'very big app'), thus I inflated the archive + copy the contents using the terminal command lines. Maybe something was missed that way round?

You need a current SVN checkout. The snapshots are too old

Jonas Maebe
to Unknown author: I've downloaded the latest shapshots available on the web page (both June and July…
I've downloaded the latest shapshots available on the web page (both June and July version).

It was probably fixed later.

Show quoted text 6 lines
Something which could matter: I couldn't use the standard installer (aborted trying to install something called 'very big app'), thus I inflated the archive + copy the contents using the terminal command lines. Maybe something was missed that way round?

No, probably not. But that installer was created via the command line with an apparently incomplete configuration, so packagemaker used some wrong defaults.

Jonas

Jonas Maebe
to Peter Vreman: You need a current SVN checkout. The snapshots are too old
Peter Vreman wrote 12 lines
> I've downloaded the latest shapshots available on the web page > (both June > and July version). Something which could matter: I couldn't use the > standard > installer (aborted trying to install something called 'very big > app'), > thus > I inflated the archive + copy the contents using the terminal command > lines. > Maybe something was missed that way round? You need a current SVN checkout. The snapshots are too old

The problem is that this support is only in 2.1.1, and debugging info in 2.1.1 is completely broken at this time (at least for classes). So you would have to checkout a revision from 2 weeks ago or so.

svn info on http://www.freepascal.org/wiki/index.php/SVN_Migration

Jonas