Code: Select all
EnableExplicit
Structure var
*m.DRI
EndStructure
define r.i,v.var
r.i=v.var\m
debug r
Code: Select all
EnableExplicit
Structure var
*m.DRI
EndStructure
define r.i,v.var
r.i=v.var\m
debug r
As PureBasic is intended to be an easier C, the whole behaviour is correct.procedure test(*S.MyStructure)
;...
endProcedure
define *T.AnotherStructure
test(*T) ; -> no compiler complain here
define T1.AnotherStructure
test(*T) ; -> no compiler complain here
Then why in this code compiler reports an error?Fred wrote:It's the intended behaviour to allow circular dependencies
Code: Select all
Declare Proc(*x.MyStruct)
Structure MyStruct
x.l
y.i
EndStructure
s.MyStruct
Proc(@s)
Procedure Proc(*x.MyStruct)
If *x
*x\x = 2
*x\y = 4
EndIf
EndProcedure
Code: Select all
Proc(@s)
Code: Select all
Proc(s)
Code: Select all
;Declare Proc(*x.MyStruct)
Structure MyStruct
x.l
y.i
EndStructure
Procedure Proc(*x.MyStruct)
If *x
*x\x = 2
*x\y = 4
EndIf
EndProcedure
s.MyStruct
Proc(@s)
Code: Select all
Structure aStruc
a.I
b.I
EndStructure
Define.aStruc X
Debug X
Debug @X
Code: Select all
Structure var
*a
EndStructure
And what does this have to do with the contribution of User_Russian?Olliv wrote:@UserRussian
Why?Code: Select all
Proc(@s)
s is already declared as a hidden pointor. Add @ prefix tells us the procedure won't treat x or y, but an other structure managing internal pointor. This last one not defined here.
seems to be the normal way.Code: Select all
Proc(s)
Although this is not directly related to User_Russian's contribution, it should be up to each user to decide how to arrange his procedures. Personally I prefer to arrange my procedures as they belong together and that is not possible without 'Declare'.skywalk wrote:I am not a fan of wasted lines and Declares.
I have ~100k lines of code with maybe 3 Declares.(Prototypes are not Declares.)
This issue is solved by proper ordering for a single pass compiler.
The error can easily be removed with only a slight modification:User_Russian wrote:Then why in this code compiler reports an error?
Code: Select all
;Declare Proc(*x.MyStruct)
Declare Proc(*x) ;The structure of a pointer is not required for a parameter of a Declare procedure.
Structure MyStruct
x.l
y.i
EndStructure
s.MyStruct
Proc(@s)
Procedure Proc(*x.MyStruct)
If *x
*x\x = 2
*x\y = 4
EndIf
EndProcedure
Fred was not talking about Declare().User_Russian wrote:Then why in this code compiler reports an error?Fred wrote:It's the intended behaviour to allow circular dependencies
You forget skywalk contribution : I do not know this technic about @StructuredVariable, not to say @StaticPointor.Integer .Josh wrote:And what does this have to do with the contribution of User_Russian?
Code: Select all
Structure void
EndStructure
Declare proc1(*a.void)
Declare proc2(*a)
Procedure proc1(*a.integer)
EndProcedure
Structure Something
FirstOne.I
EndStructure
Procedure proc2(*a.Something)
EndProcedure
Code: Select all
Structure aStruc
*a.DontCare ; size of integer
b.OtherStruc ; size of OtherStruc
EndStructure
Code: Select all
Structure IamFine
*MS.MainScreen
*SoAs.SizeOfAreas
*PsF.PreferencesFile
EndStructure
Code: Select all
Structure IamTired
*MS
*SoAs
*PsF
EndStructure