Restored from previous forum. Originally posted by PB.
If a procedure isn't called, it shouldn't be compiled into the exe.
PB - Registered PureBasic Coder
Don't compile uncalled procedures
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Rings.
Procedure DoAnything(Damm.l,Damm2)
..
..
EndProcedure
SetWindowsCallBack(@DoAnything)
So You can Check for the use of a procedure.
Its a long way to the top if you wanna .....CodeGuru
if you use a procedure for a Callback, you have to deal with the ProcedurePointer:What about procedures, that are set up as hooks or callbacks via API?
How should the compiler know that?
Procedure DoAnything(Damm.l,Damm2)
..
..
EndProcedure
SetWindowsCallBack(@DoAnything)
So You can Check for the use of a procedure.
Its a long way to the top if you wanna .....CodeGuru
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
> What about procedures, that are set up as hooks or callbacks via API?
> How should the compiler know that?
Easily! All the compiler has to do is get all procedure names, then check if any
references to them exist in the code. If not, don't compile the uncalled ones.
For example:
So, the compiler sees that Two() and Four() are never referenced, and therefore
shouldn't compile them into the final exe. I really don't see any problem.
PB - Registered PureBasic Coder
> What about procedures, that are set up as hooks or callbacks via API?
> How should the compiler know that?
Easily! All the compiler has to do is get all procedure names, then check if any
references to them exist in the code. If not, don't compile the uncalled ones.
For example:
Code: Select all
Procedure One()
MessageRequester("title","one",0)
EndProcedure
;
Procedure Two()
MessageRequester("title","two",0)
EndProcedure
;
Procedure Three()
MessageRequester("title","three",0)
EndProcedure
;
Procedure Four()
MessageRequester("title","four",0)
EndProcedure
;
; REST OF APP
;
SetWindowsCallBack(@One) ; Procedure One() is referenced.
Three() ; Procedure Three() is referenced.
shouldn't compile them into the final exe. I really don't see any problem.
PB - Registered PureBasic Coder
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by fweil.
Mmmmm ...
Don't know if I definitely agree, because you may have some special coding containing FakeReturn for example that could make a coder unhappy.
Usually it is better to have conditional compilation using Compiler directives.
I am not sure about what I write there ... just an opinion.
Rgrds
Francois Weil
14, rue Douer
F64100 Bayonne
Mmmmm ...
Don't know if I definitely agree, because you may have some special coding containing FakeReturn for example that could make a coder unhappy.
Usually it is better to have conditional compilation using Compiler directives.
I am not sure about what I write there ... just an opinion.
Rgrds
Francois Weil
14, rue Douer
F64100 Bayonne
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
> Don't know if I definitely agree, because you may have some special coding
> containing FakeReturn for example that could make a coder unhappy.
FakeReturn is used with Gosub, not Procedures, so this isn't an issue.
Basically, if you never call a procedure, then nothing else in your app
is going to reference it, because an uncalled procedure is just useless
code in the executable.
Fred, isn't that right?
PB - Registered PureBasic Coder
> Don't know if I definitely agree, because you may have some special coding
> containing FakeReturn for example that could make a coder unhappy.
FakeReturn is used with Gosub, not Procedures, so this isn't an issue.
Basically, if you never call a procedure, then nothing else in your app
is going to reference it, because an uncalled procedure is just useless
code in the executable.
Fred, isn't that right?
PB - Registered PureBasic Coder
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by MrVainSCL.
Hi PB
I agree with you... unused Procedures() should not be included/compiled to the final executeable, bcoz its only unused code in your exe you will never call!
We just need a better compiler, with automactical checking if all Proecdures in a program (mainsource + checking of procedures in external include files too, are very important!)... Else the compiler would create maybe to big (include unneeded) or to less (remove needed) Proecdures to the exe...!? For example...:
The "MainProgram.pb" will include "Include_1.pb" and "Include_2.pb"... We have Proc1() and Proc2() in our "MainProgram.pb" but only use Proc(2)... So the compiler have only to add/compile Proc2()to the exe and ignore Proc1()
In our "MainProgram.pb" we still use Proc3(), Proc5() and Proc6()... So the compiler have to check all Procedures and verify to all files (mainsource + includefiles) if we still use any of the procedures somewhere else... In this example, the compiler have the include file "Include_1.pb" and in this file will only be this two procedures = Proc3() and Proc4()... We will call Proc3() only in our MainFile.pb... So the compiler has only to add this one procedure... both not both...
Anyway if the compiler see this too procedures only (no other code) in the include file "Include_1.pb" he dont have to ignore this... First checking all sources.. (main + includes)...
Hope you all understand what i wanted to say...
[/u]Another great feature:[/u]
We need a compiler who include ONLY the really needed PB-Commands... Ok, some libs (but not all) are splitted yet... For example the next libs we could spilt up... ScreenLib, GadgetLib, GadgetExtension, Image....!?
Happy coding...
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...
greetz
MrVainSCL! aka Thorsten
Hi PB
I agree with you... unused Procedures() should not be included/compiled to the final executeable, bcoz its only unused code in your exe you will never call!
We just need a better compiler, with automactical checking if all Proecdures in a program (mainsource + checking of procedures in external include files too, are very important!)... Else the compiler would create maybe to big (include unneeded) or to less (remove needed) Proecdures to the exe...!? For example...:
Code: Select all
MainProgram.pb -> InSource: Proc1(), Proc2() -> Required: Proc2()
Include_1.pb -> InSource: Proc3(), Proc4() -> Required: Proc3()
Include_2.pb -> InSource: Proc5(), Proc6() -> Required: Proc5, Proc6
The "MainProgram.pb" will include "Include_1.pb" and "Include_2.pb"... We have Proc1() and Proc2() in our "MainProgram.pb" but only use Proc(2)... So the compiler have only to add/compile Proc2()to the exe and ignore Proc1()
In our "MainProgram.pb" we still use Proc3(), Proc5() and Proc6()... So the compiler have to check all Procedures and verify to all files (mainsource + includefiles) if we still use any of the procedures somewhere else... In this example, the compiler have the include file "Include_1.pb" and in this file will only be this two procedures = Proc3() and Proc4()... We will call Proc3() only in our MainFile.pb... So the compiler has only to add this one procedure... both not both...
Anyway if the compiler see this too procedures only (no other code) in the include file "Include_1.pb" he dont have to ignore this... First checking all sources.. (main + includes)...
Hope you all understand what i wanted to say...
[/u]Another great feature:[/u]
We need a compiler who include ONLY the really needed PB-Commands... Ok, some libs (but not all) are splitted yet... For example the next libs we could spilt up... ScreenLib, GadgetLib, GadgetExtension, Image....!?
Happy coding...
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...
greetz
MrVainSCL! aka Thorsten
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
> I agree with you... unused Procedures() should not be included/compiled
> to the final executeable, bcoz its only unused code in your exe you
> will never call!
My app, PBToolBox, has a feature that shows you which procedures are
never called so you can remove them manually. Unfortunately it can't
check IncludeFile files, but it's a start.
See the Announcements
section for details.
PB - Registered PureBasic Coder
> I agree with you... unused Procedures() should not be included/compiled
> to the final executeable, bcoz its only unused code in your exe you
> will never call!
My app, PBToolBox, has a feature that shows you which procedures are
never called so you can remove them manually. Unfortunately it can't
check IncludeFile files, but it's a start.

section for details.
PB - Registered PureBasic Coder
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by MrVainSCL.
Hi @ all
Let us wait for the next version... Maybe Fred can add this feature for the next version?
Would be nice to have...
PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...
greetz
MrVainSCL! aka Thorsten
Hi @ all
Let us wait for the next version... Maybe Fred can add this feature for the next version?

PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...
greetz
MrVainSCL! aka Thorsten