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: Code Composer Studio
Hi,
I am developing a static library to avoid code duplicates within three similar products.
The products are using cc3235 and cc3220 and are built with ccs 9.3 with compiler 18.12.4.
In the static library, I want to put a function which has just a small part which varies for the different projects.
See below an example which I hope to be understandable enough ; )
//Static lib project extern void product1Function(); int genericFunction(bool isProduct1) {
// do something generic
if (isProduct1) { product1Function() } } //Product1 project void product1Function() { //Do something } void main() { genericFunction(true) } //Product2 project void main() { genericFunction(false) }
In Product2 project, I currently get the error Unresolved symbol product1Function. Is it possible to have the linker understand that this will never be called and remove the whole non callable chunk?
Thanks,
Cédric
The key piece to understand is that this if statement ...
Cedric Gerber said:
if
(isProduct1)
{
product1Function()
}
... occurs at run time, not build time. If you build with optimization level 4 (--opt_level=4), the compiler may automatically propagate the false value in this call ...
Cedric Gerber said:
genericFunction(
false
)
... into that function in the library, and then get rid of the undesired call. But there is no guarantee this optimization will always succeed.
Thanks and regards,
-George