Re: Techniques to reduce executable size
Qu0ll wrote:
I come from a Java world where we have tools like ProGuard which analyze
all the components of an application and strip out classes and members
that are not being used. Is there an equivalent in C++ or does this
happen automatically?
C++ has a concept, related mostly to templates, that you don't pay for
what you don't use. Compiler implementors develop their tools with
reduced program size in mind, of course, it's always one of the goals.
For example, linkers (the programs that tie different object modules
together) can perform some reduction by not linking modules from which
no function is used.
> For example, if I use one or two classes in the
Boost library, do I get the entire library when I link my program?
Most likely not.
Similarly if I use just part of the STL, do I get the whole thing or
just those parts I use?
Only the parts that you use. That's one of the selling points of C++
templates.
The overall reduction in machine code is not always possible by the
compiler/linker, since the use of functions/modules can be dependent on
the data the program has to process. Theoretically, if you have an
exhaustive set of tests, you can run your program under a *coverage*
tool to collect coverage data and then manually remove the code that is
never executed.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask