linux – How to analyze the code for unused functions?

Question:

The code is written in C.

The -Wall flag can only show local functions. What about the global ones?

What code analysis tools are there? As far as I understand, we can see this at the stage of linking all object objects into one? Can the linker show it?

Answer:

Let me clarify that this is for the case of static code analysis – the search for functions that are not accessed by the code. The cppcheck utility can help you, it also has a very large list of various checks, besides finding unused functions.

If you want to see what methods were called during execution, then their list may differ depending on the input data, you can use valgrind to view them.

Scroll to Top