This is by design. Nothing except the PB stuff can be created outside and used inside a module.
Recommendation: Use a Common Modul for that.
Warning: this does not following any design rules..
DeclareModule Common
#Constant = 123
Structure TWhatEver
Name.s
EndStructure
Global Test.TWhatEver
EndDeclareModule
; can be empty, but must declared
Module Common
EndModule
DeclareModule Main
UseModule Common
EndDeclareModule
Module Main
Test\Name = "Test"
Debug #Constant
Debug test\Name
EndModule
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).
Create a resident file (x86 & x64) with the global structure, restart the compiler and the global structure will be available directly without declaring it.
Denis wrote: Thu May 22, 2025 4:46 pm
I don't know if it still rocks in 2025.
Create a resident file (x86 & x64) with the global structure, restart the compiler and the global structure will be available directly without declaring it.
kinglestat wrote: Thu May 22, 2025 5:17 pm
Thanks
Good idea re common module
but what happens to global variables? are they reset if used in another module?
No, common global variable not reinit. Otherwise it doesn't make sense
Denis wrote: Thu May 22, 2025 4:46 pm
I don't know if it still rocks in 2025.
Create a resident file (x86 & x64) with the global structure, restart the compiler and the global structure will be available directly without declaring it.
But a resident file is cross-project ...
you're right mk-soft.
But there are more than 700 predeclared structures in PB resident files (windows version), so cross-project, and that certainly satisfies a lot of coders...