Tool/software: TI C/C++ Compiler
Hello,
When I use just a single function taken from a .h file, among the several ones can populate the file, does the compiler allocate also those functions I do not use ?
Regards,
-Marco
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: TI C/C++ Compiler
Hello,
When I use just a single function taken from a .h file, among the several ones can populate the file, does the compiler allocate also those functions I do not use ?
Regards,
-Marco
I presume this header file only contains the function prototypes, and not the full implementation of the functions. In that case, a prototype for a function that is not called has no effect. This FAQ (not from TI) may be helpful.
Thanks and regards,
-George
Well, I performed a test with 2 programs. Both include a .h files but only one calls one of the declared functions. Looking at the linker map, it seems that even if you include the .h file the compiler creates the object but does not link it to the executable. But, as soon as you call just one of the function it links and allocate all of the functions (by linking the related object).
So, in other words it seems it compiles all the functions even if you use just one of them. Is there any option to set it up to compile only function(s) that you actually use in the program ?
When I used/escluded the functions from the .h file, I tried with adding/commenting rtiInit() from rti.c/.h. Well, that function does not seem to call other functions, but rather an initialization of variables.
As I described above, even including rti.h in the sys_main file, if I do not call rtiInit(), the compiler correctly does not link any object related to rti (i.e. rti.obj), while if I call rtiInit(), it links each function of rti.c.
However, I tried also by creating my own set of functions (e.g. functions.c/.h) containing very basic operations not "explicitally" related each other like addition (var1 + var2), subtraction, multiplication, etc. So, when I use, for example, only the addition the compiler allocates also the other functions anyway.
I have ARM Optimizing C/C++ Compiler v16.9.0.LTS and I cannot find information about --gen_function_subsections in its manual; the same searching into the manual of the v18.1.0.LTS. There is --gen_data_subsections instead, but I suppose that is another scope. Is it possible --gen_function_subsections was introduced in other versions? If yes, can you tell me which one ?
I'm sorry, the option is actually --gen_func_subsections, I got that wrong earlier. It is certainly available in 16.9.0.LTS
The examples I gave used only functions and function calls, but it is possible for functions to drag in other functions by way of variable references.
When making your own tests, make sure you either use ---gen_func_subsections or put each function in its own input file.