Page 1 of 1

compiler uses only used functions ?

Posted: Thu Nov 30, 2006 12:18 pm
by MyTrial
Hi

I have a dummie question: Is the compiler optimised that not used functions are not in the compiled program?

Why I ask: I made some sub source files with global handling functions and bind them in my program source with XIncludeFile. When I make a program with much of all functions the compiled file size is nearly same as a program with only one function of that used (PB3.94).

Or should I use an other way to do that?
But I do not want DLLs or separate files to handle.

Many thanks for your help.
SKER

Posted: Thu Nov 30, 2006 1:12 pm
by AND51
No, the PB4 changelog says, that procedures who are used will be compiled.

I asked this a long time ago, and I made a test:

Code: Select all

Procedure AND51()

; Code, and what eveer you want

EndProcedure
Write this without calling the procedure and you see: the EXE is bigger than a EXE without any code :shock:

Posted: Thu Nov 30, 2006 2:02 pm
by Konne
Nope. Non used functions are not included. But if u use strings they are.
Just try it.

Code: Select all

procedure Test()
Me.l='tseT'
endprocedure
Do u find any "Test" in the exe?

Posted: Thu Nov 30, 2006 2:21 pm
by remi_meier
This compiler feature is very restricted (reason: I think the speed of the
compiler).

Code: Select all

procedure test()
  a+4
  procedurereturn a
endprocedure
won't be included, but

Code: Select all

procedure test1()
  a+4
  if a = 5
    test2()
  endif
  procedurereturn a
endprocedure
procedure test2()
  test1()
endprocedure
there both procedures will be included. The feature only works if there is
NO (not a single) reference to the procedure in the code, even if this
reference is in another not used procedure, the procedure will be included.


So: Mostly, from a bit more complex function libraries most of the functions
will be included.

Posted: Thu Nov 30, 2006 2:31 pm
by gnozal
Another possibility is to use a user library instead of an include.

AFAIK, only used userlib functions are included.