If i have a module that contains several functions/subs, is it safe to assume only the code that is called is compiled into the final downloaded.
i.e. if i put all functions relating to an esp8266 in a module, but don't call some of them from a particular MAIN program, does unused code occupy any space ?
Code size
Re: Code size
Yes. This type of optimization is implemented on two levels for native mode devices. Firstly, when the ZBasic compiler is producing C or C++ code, it only generates code for the procedures that are referenced (unless the ZBasic optimization directs otherwise). Secondly, when the back end compiler processes the generated code it also optimizes to remove unused code.FFMan wrote:If i have a module that contains several functions/subs, is it safe to assume only the code that is called is compiled into the final downloaded.
Of course, determination of whether a procedure is unused is done using static analysis, i.e. if there is a invocation reference to a procedure that might be followed it is considered "used" even it the procedure is never actually invoked at run time.
You can test this by noting the code size, adding an unused subroutine and then noting the resulting code size.
- Don Kinzer