Forward Declarations

Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1373
Registered: 03 / 2005
Subject:

Forward Declarations

 · 
Posted: 10.08.2010 - 14:24  ·  #1
@ Rolf.

In the compiler manual the following is described

Code
type TPtr = pointer; forward; // preliminary declaration
TRec1 = record
Ptr1 : TPtr;
end;
TPtr = pointer to Trec1; // main declaration


(I have removed "...")

This does not compile - I get the error "Error: Duplicate declaration".

Regards

Merlin.

p.s. I should have said that this is in the interface section of a unit.


pps Here is a work around. Maybe manual needs to be changed? It is more logical any way:

Code
type TRec1 = record; forward; // preliminary declaration
TPtr = pointer to Rec1;
TRec1 = record
Ptr1 : TPtr;
end;


This compiles OK
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Forward Declarations

 · 
Posted: 11.08.2010 - 21:18  ·  #2
Hello Merlin,

ok, the first failure is a limitation. But I'm pretty unsure what I can write into the manual to warn the user...

rolf
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1373
Registered: 03 / 2005
Subject:

Re: Forward Declarations

 · 
Posted: 12.08.2010 - 09:43  ·  #3
Hi Rolf.

Just give a different example, (i.e. one that compiles) such as my work-around. As long as there is a way and the example is valid I think that is fine, but there should not be an example in the manual that does not compile.

Cheers

Merlin.
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Forward Declarations

 · 
Posted: 12.08.2010 - 20:31  ·  #4
Hello Merlin,

where did you find this bad sample?

rolf
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1373
Registered: 03 / 2005
Subject:

Re: Forward Declarations

 · 
Posted: 13.08.2010 - 09:41  ·  #5
Hi Rolf.

It is in DocuCompiler.pdf section 4.1.17 - page 33, and then again on page 71 (I also noticed a typo, Funktion instead of Function an that page).

Regards

Merlin.
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Forward Declarations

 · 
Posted: 13.08.2010 - 13:20  ·  #6
Hello Merlin,

thank you.

rolf
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   108   122 · Page-Gen-Time: 0.028001s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI