Page 1 of 1
pointer to a not defined struct in struct
Posted: Sun Dec 28, 2008 11:11 pm
by luis
Code: Select all
Structure TEST
a.i
b.whatisthat
EndStructure
the compiler gives an error in this case
Code: Select all
Structure TEST
a.i
*b.whatisthat
EndStructure
but nothing in this case
Has this been reported already ?
I believe I saw something similar posted in the forum but I'm not sure...
Posted: Sun Dec 28, 2008 11:36 pm
by Psychophanta
The compiler ignores the type of the pointer vars.
A pointer is indeed always a .i variable (so then a .i length variable), but it points to a specific type of data, which, in my opinion, should be written just like your example does.
Posted: Sun Dec 28, 2008 11:40 pm
by freak
It is to allow references to structrures which will be defined later.
Otherwise something like this would not be possible:
Code: Select all
Structure StructA
*p.StructB
EndStructure
Structure StructB
*p.StructA
EndStructure
Posted: Sun Dec 28, 2008 11:44 pm
by Psychophanta
Whith that you have gave me this mad idea...
... what if:
Code: Select all
Structure StructA
p.StructB
EndStructure
Structure StructB
p.StructA
EndStructure

Posted: Mon Dec 29, 2008 12:47 am
by Kaeru Gaman
I agree: it is a mad idea...
Posted: Mon Dec 29, 2008 12:55 am
by Mistrel
freak wrote:It is to allow references to structrures which will be defined later.
Is this kind of behavior necessary in a single-pass compiler?
Posted: Mon Dec 29, 2008 1:00 am
by freak
Psychophanta wrote:Whith that you have gave me this mad idea...
... what if:
Code: Select all
Structure StructA
p.StructB
EndStructure
Structure StructB
p.StructA
EndStructure

If this worked, there would be endless recursion.
> Is this kind of behavior necessary in a single-pass compiler?
Well, you could also have a way to declare a structure before actually defining its content (like you can do in C) but thats a bit overkill imho.
Posted: Mon Dec 29, 2008 1:07 am
by idle
why the question?
Code: Select all
Structure StructA
*p.StructB
mdat.i
something.w
another.w
EndStructure
Structure StructB
*p.StructA
mdat.i
EndStructure
mA.StructA
mB.StructB
ma\mdat = 999
mb\mdat = 666
mA\p = @mb
mb\p = @ma
Debug ma\mdat
Debug mA\p\mdat
Debug mb\mdat
Debug mb\p\mdat
Mindyou pointer references like this, mostly do my head in
And it can make it tricky dealing with structures in C libs
when they reference each other without pointers
Posted: Mon Dec 29, 2008 1:15 am
by luis
freak wrote:It is to allow references to structrures which will be defined later.
OK, make sense.
Thank you.
Posted: Mon Dec 29, 2008 12:50 pm
by srod
For God's sake do not change this behaviour - my code relies on it quite heavily!