I am wondering what the overhead is of having unused functions in your code.
Say for example you have some debug logging, and you then give most of your objects a To
1. Regarding Compilers and Linkers
It really depends how you create your executable.
Typically executables are stripped of anything that is not used. Therefore if you link statically (and with the right optimization options) the functions will get removed.
However if you link dynamically, they'll be there, because as far as the library is concerned, they are exported and therefore used.
As for the multiple definitions, it depends if the symbol is weak. If it's weak, the linker picks one of the definitions, otherwise it chokes on it.
Finally, they probably only represent a marginal part of your program.
2. How to solve the issue ?
It's a hard problem, you can always use the preprocessor to remove some stuff, but code that is littered with preprocessor directives is really annoying to read.
Personally, I would not bother... especially because I log in Release too (how else tracking down production issues ?).
A solution could be to define the offending functions in a separate file and not link them in Release. Note: I do not think it works for virtual functions, since they are at least used in the vtable