Peter Schorn wrote:
Dear all,
while porting from CodeWarrior Object Pascal to GPC I noticed the following differences which might be worthwhile to address in GPC.
- Mutual recursive object type declaration
As long as you aren't inheritting from another object, you can use a forward object type declaration in both GPC and CodeWarrior Pascal for mutually recursive onject type declarations.
program prog1; { compile with gpc --mac-pascal prog1.pas } type
t2 = object; forward;
t1 = object function f: t2; { error: unknown identifier `t2' }
{ above works in CodeWarrior Object Pascal as objects are always references } end;
t2 = object function g: t1; end;
function t1.f: t2; begin f := nil; end; function t2.g: t1; begin g := nil; end; begin end.
As a workaround this can be solved by introducing a common super class and subsequent casting.
With the added forward object declaration for t2, GPC compiles the example with no errors.
Gale Paeper gpaeper@empirenet.com