Add dead code warning of C code to Visual Studio 2022

piutty 1 Reputation point
2022-12-21T13:48:45.853+00:00

I use Visual Studio 2022 to build my C project and OpenCppCoverage to check the coverage.

With these tools, I don't find how to find C functions (static & public) that aren't called. The /Zi option may not produce a PDB with the uncalled function and OpenCppCoverage is unable to detect it:

272935-image.png

As the goal is to detect dead code, one option is to add a warning to visual studio 2022 compilator or linker to raise an error in case of unused function as gcc or to produce a PDB that contain information about the uncalled function (The second option may not work).

Anyone have an idea to detect dead code with these tools?

Developer technologies C++
Developer technologies Visual Studio Other
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.