Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find unused structure definitions in C automatically?

Tags:

c

gcc

GCC will warn on unused functions, labels, etc. But it seems it doesn't warn on unused definitions? Is there a way to detect unused struct definitions automatically?

like image 792
Coiby Avatar asked Sep 18 '25 12:09

Coiby


1 Answers

You won't necessarily be able to identify individual structs but there is a tool called include-what-you-use which allows you to eliminate unused includes. See here: https://include-what-you-use.org/

and here for using with CMake: How to use the tool include-what-you-use together with CMake to detect unused headers?

like image 65
Den-Jason Avatar answered Sep 20 '25 05:09

Den-Jason