Build Question?

Just starting out? Need help? Post your questions and find answers here.
vwidmer
Enthusiast
Enthusiast
Posts: 282
Joined: Mon Jan 20, 2014 6:32 pm

Build Question?

Post by vwidmer »

If I am using include files in my program and there are procedures in the includes that I am not using do they still get built into the program?

Will it add extra size to it?

Thanks
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA
User avatar
mk-soft
Always Here
Always Here
Posts: 5405
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Build Question?

Post by mk-soft »

If there is no mutual reference, unused procedures are not compiled.

Code: Select all

Procedure foo1() ; compiled because referenced into foo2()
  ProcedureReturn 1  
EndProcedure

Procedure foo2() ; Not compiled because not called
  ProcedureReturn foo1()
EndProcedure

Procedure foo3() ; Compiled because called from main scope
  ProcedureReturn 3
EndProcedure

a = foo3()
Debug a
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Build Question?

Post by Dude »

mk-soft wrote:If there is no mutual reference, unused procedures are not compiled.
But be aware that some data and commands inside uncalled procedures are still compiled into the exe. Observe:

Code: Select all

Procedure ThisProcedureIsNeverCalled()
  a$="but this text is compiled into the final exe regardless"
  UseJPEGImageDecoder() ; And this adds 111 KB to the exe size.
EndProcedure

MessageRequester("test","test")
So it's better to run a pre-compiler to strip out all uncalled procedures, if you don't want their contents included in the exe.
vwidmer
Enthusiast
Enthusiast
Posts: 282
Joined: Mon Jan 20, 2014 6:32 pm

Re: Build Question?

Post by vwidmer »

Sorry but what do you mean by pre-compiler or how to use it?

Thanks
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Build Question?

Post by Dude »

I mean there are tools (available from this forum) that strip out dead or unused procedures so you can create your exes with less bloat.

Here's a link to one: http://www.purebasic.fr/english/viewtop ... 05#p434105

And you can search these forums for "unused procedures" for more discussion. ;)
Post Reply