https://www.purebasic.com/documentation ... dents.html
Residents are precompiled files which are loaded when the compiler starts. They can be found in the 'residents' folder of the PureBasic installation path. A resident file must have the extension '.res' and can contain the following items: structures, interfaces, prototypes, macros and constants. It can not contain dynamic code or procedures.
When a resident is loaded, all its content is available for the program being compiled. That's why all built-in constants like #PB_Event_CloseWindow are available, they are in the 'PureBasic.res' file. All the API structures and constants are also in a resident file. Using residents is a good way to store the common macros, structure and constants so they will be available for every programs. When distributing an user library, it's also a nice solution to provide the needed constants and structures, as PureBasic does.
To create a new resident, the command-line compiler needs to be used, as there is no option to do it from the IDE. It is often needed to use /IGNORERESIDENT and /CREATERESIDENT at the same time to avoid duplicate errors, as the previous version of the resident is loaded before creating the new one.
Residents greatly help to have a faster compilation and compiler start, as all the information is stored in binary format. It is much faster to load than parsing an include file at every compilation.
Everything is described simply and logically, but
pbcompiler -h
or
pbcompilerc -h
/CREATERESIDENT: Unknown switch
Can someone give an example of creating and using a custom res file?
/CREATERESIDENT
/CREATERESIDENT
Last edited by useful on Sat Oct 12, 2024 6:16 am, edited 1 time in total.
Dawn will come inevitably.
Re: /CREATERESIDENT
I answer myself.
For example
OnOff.pb
t. e. error in the documentation and the key /IGNORERESIDENT REQUIRED!
... pbcompiler OnOff.pb /IGNORERESIDENT OnOff.res /RESIDENT OnOff.res /QUIET
For example
OnOff.pb
Code: Select all
#ON=1
#OFF=0
... pbcompiler OnOff.pb /IGNORERESIDENT OnOff.res /RESIDENT OnOff.res /QUIET
Last edited by useful on Sat Oct 12, 2024 6:17 am, edited 1 time in total.
Dawn will come inevitably.
Re: /CREATERESIDENT
From my batch file in my PureBasic folder:
The file "MyResidents.pb" holds my definitions.
Code: Select all
del "Residents\[MyResidents].res"
"Compilers\pbcompiler.exe" MyResidents.pb /resident [MyResidents].res
move [MyResidents].res "Residents\"
pause
Re: /CREATERESIDENT
I have already found out everything for myself and pointed out above that there is an error in the documentation. Well, or the documentation is correct (as intended), but not implemented correctly. 

Dawn will come inevitably.