Page 1 of 1

PB4 beta11 - Linking unused procedures to exe

Posted: Fri Apr 21, 2006 9:36 pm
by va!n
i think i have read somewhere that PB4 will automatical check what procedures are used and checking what procedures are not used. It would be great, if PureBasic (also the compiler) will do a precompilation of the main source (including all include files) and check if there are any unused procedures to cut them out, before compiling to an executeable!

i have tested it following small source and showing cutting off unused procedures isnt supported or does not work :cry:

A feature like this would be very usefull, because i have some include files and its sad to compile the complete includefile to the exe, when using only one small procedure from it!

Code: Select all

Procedure Temp1()
  UseJPEGImageDecoder()
  UseJPEGImageEncoder()
EndProcedure

Procedure Temp2()
  UsePNGImageDecoder()
  UsePNGImageEncoder()
EndProcedure

Procedure Temp3()
  UseTGAImageDecoder()
  UseTIFFImageDecoder()
EndProcedure

Procedure Test()
  MessageRequester("Procedure Compiling Test","Linking unused Procedures?",0)
EndProcedure

Test()
End

Posted: Fri Apr 21, 2006 9:40 pm
by Trond
Actually, the procedures themselves aren't in the final executable even though the image decoders are. :?: Just look at the generated assembly code.

In this case, however, it seems like both procedures are in the final executable:

Code: Select all

Declare Temp1()
Declare Temp2()

Procedure Temp1()
  Temp2()
EndProcedure

Procedure Temp2()
  Temp1()
EndProcedure



Posted: Fri Apr 21, 2006 10:05 pm
by Rescator
va!n the best way to do this would be to use compiler if's and compiler conditions to check and include the image decoder if it has not been included before.
This should reduce such issues!