If a procedure is not linked (directly or via a chain of procedures) to the main program code, does it get included in the compiled exe or is it left out, to reduce filesize?
What about structures that are never used, etc.?
Do orphan procedures get compiled?
-
Seymour Clufley
- Addict

- Posts: 1267
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
- Kaeru Gaman
- Addict

- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
I'm not sure if it is solved meanwhile...
in earlier versions, procedures that were never called were left out,
Procedures that were called from Procedures were implemented,
even if the calling Procedure was never called.
there are plugins/preparser to deal with that, I think...
Structures are not at all implemented in the exe in a form that needs memory,
they are only a construct to describe complex offset combinations in a way readable for Humans.
in earlier versions, procedures that were never called were left out,
Procedures that were called from Procedures were implemented,
even if the calling Procedure was never called.
there are plugins/preparser to deal with that, I think...
Structures are not at all implemented in the exe in a form that needs memory,
they are only a construct to describe complex offset combinations in a way readable for Humans.
oh... and have a nice day.
They do get compiled under 4.20, I think...
Creating an executable with 4.20 and this:
... resulted in a file of 3.584 bytes.
Using this:
... resulted in an executable of 68096 bytes.
4.30's exe was about 600 bytes larger.
(Still not bad realizing that x_lib is about 5000 lines. And before someone asks: everything in that file x_lib is enclosed in procedures so should not add to exe size unless procedures are included.)
Creating an executable with 4.20 and this:
Code: Select all
; IncludeFile "c:\software\purebasic\_projects\x_lib\x_lib.pb"
a = 1
Debug "Ok"
Using this:
Code: Select all
IncludeFile "c:\software\purebasic\_projects\x_lib\x_lib.pb"
a = 1
Debug "Ok"
4.30's exe was about 600 bytes larger.
(Still not bad realizing that x_lib is about 5000 lines. And before someone asks: everything in that file x_lib is enclosed in procedures so should not add to exe size unless procedures are included.)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Generally speaking procedures which are not referenced at all will not be included in the final exe.
Consider the following :
In this case neither function will be included in the final exe because neither is referenced anywhere in the code.
However, in the following code :
the procedure test1() will be included in the final exe even though it is only referenced within test2() which itself will not be included in the final exe.

Consider the following :
Code: Select all
Procedure test1()
a+1
EndProcedure
Procedure test2()
a+1
EndProcedure
a + 5However, in the following code :
Code: Select all
Procedure test1()
a+1
EndProcedure
Procedure test2()
a+1
test1()
EndProcedure
a + 5I may look like a mule, but I'm not a complete ass.
@srod: The following example has DeleteFileA and MessageBoxA in the final
exe, but I don't know whether the procedure code is included or just the API
headers:
exe, but I don't know whether the procedure code is included or just the API
headers:
Code: Select all
Procedure test1()
DeleteFile(a$)
EndProcedure
Procedure test2()
MessageRequester("","")
EndProcedure
a + 5
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
