[Question] Library development linker optimizations

Hello!

I would like to clarify something master programmers.

  1. I am doing an arduino library and I want to minimize the code and memory footprint. I have a class (let's call it Simple) that offers some basic functions to interact with a device. Then I have a subclass of Simple (let's call it Advanced). I did that thinking if the user only wanted simple functions we would no need code from the advanced. It is true that the linker eliminates "dead" functions from the assembly code that goes on the board?

  2. The same principle applies class fields objects? if a field from a class isn't used in the code it is somehow removed from the assembly? This one I have real doubts about it.

Many thanks

  1. Yes. It's incredibly efficient at it.

  2. What do you mean? The data storage required for a class is defined by the public and private variables you declared in the class. The compiler won't arbitrarily compress the class and slice off variables just because you don't use them.