Do unused functions get optimized out?

It depends on the compiler. Visual C++ 9 can do that – unused static functions are removed at compilation phase (there’s even a C4505 warning for that), unused functions with external linkage can be removed at link phase depending on linker settings.

Leave a Comment