How different compilers deal with provably unused entities
quuxplusone.github.io
quuxplusone.github.io
Not by default (for some reason), but the major compiler toolchains will all do it if you pass the right flags:
- Apple: Pass -dead_strip to linker
- Linux/ELF: Pass -Wl,--gc-sections to linker and -ffunction-sections -fdata-sections to compiler
- MSVC: Pass /opt:ref to linker and /Gw /Gy to compiler
(If you're building a dynamic library you also want -fvisibility=hidden on the Unix platforms.)
https://clang.llvm.org/docs/DiagnosticsReference.html#wunnee...
“warning: member function A is not needed and will not be emitted”