Yes. The structures are declared on top of each file in this order:
Main.pb -> GameState.pbi -> Match.pbi -> Player.pbi -> BattleTarget.pbi -> Match.pbi
Eacho file is included with XIncludeFile.
Structure TBattleTarget
;bunch of stuff
*Match.TMach ; <=== TMach or TMatch <=> That is the question
EndStructure
BTW: I always use this syntax for my user defined structures, and never got any problems.
Just because it worked doesn't mean it works. PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Structure TBattleTarget
;bunch of stuff
*Match.TMach ; <=== TMach or TMatch <=> That is the question
EndStructure
BTW: I always use this syntax for my user defined structures, and never got any problems.
Indeed there is a typo on the example code. I verified my source code and the declaration *Match.TMatch has the same structure name as the declaration "Structure TMatch" inside Match.pbi, the autocomplete even shows the fields for the *Match member.
well, without running code, it is difficult to make any suggestions.
So here are just a few thoughts:
In this case, do not rely on autocomplete. This is because autocompletion works with any open files.
I guess the compiler message indicates that the declaration is missing, or perhaps you have used the definition before the declaration?
Just because it worked doesn't mean it works. PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
The definition of structure TBattleTarget will compile just fine, even if TMach (or TMatch) isn't defined because the field is a pointer, so purebasic doesn't really care at that point what TMach is. But when you start to work with it and its fields like in the Debug code, then purebasic needs to know and complains about it not being defined. You need to inspect your include chain to see how you end up without TMach at that point. Do some files include each other or something like that? Maybe placing different CompilerWarning messages before and after include statements can help if you can't figure it out by just looking at your files.
ricardo_sdl wrote: Wed Apr 16, 2025 2:35 pmBut then I added this line inside a procedure:
Where did you add it?
If Match.pbi first includes Player.pbi before doing any declarations, then Player.pbi won't have those declarations from Match.pbi available. Same for BattleTarget.pbi, because even though is has its own inclusion of Match.pbi, that won't be done because XInclude (include only once) has already been started for that file in GameState.pbi, if I understand your outline correctly.
#NULL wrote: Wed Apr 16, 2025 5:52 pm
The definition of structure TBattleTarget will compile just fine, even if TMach (or TMatch) isn't defined because the field is a pointer, so purebasic doesn't really care at that point what TMach is. But when you start to work with it and its fields like in the Debug code, then purebasic needs to know and complains about it not being defined. You need to inspect your include chain to see how you end up without TMach at that point. Do some files include each other or something like that? Maybe placing different CompilerWarning messages before and after include statements can help if you can't figure it out by just looking at your files.
I didn't know the compiler wouldn't verify the type of the pointer declaration inside the structure! So it's probably that, since I have a circular dependency here leading to a "who came first? the chicken or the egg?" problem. I think one way to avoid that is spliting the declarations and definitions in two files like in C language with its .h and .c files.
Thank you all! I solved my problem for now using a procedure that returns the value I want. I'll try to structure my includes in a better way in future projects.