views:

60

answers:

1

The /OPT:REF option causes the Visual C++ linker to

Exclude functions and/or data that are never referenced

(MSDN)

This seems like it would be a good way to identify obsolete code in a legacy codebase. Is there any way to get the linker to output what is eliminated?

+1  A: 

This isn't ideal, but...

You can do two builds, one with /OPT:REF and one without, then run dumpbin /symbols on the resulting binaries, parse out the symbols, and diff the results. The trick will be weeding out the library symbols so you are only left with your symbols. Since you'll end up with a list of mangled names, it's not going to be pretty.

I don't know of a way to get the linker to just tell you what it's removing.

James McNellis