Remove unused function prototypes from a .h file

I need to remove a bunch of function prototypes from several .h files, and I was wondering if there is some kind of bash script / program to search for prototypes that are not in the .c file and automatically delete them.

This is really useful for cleaning source code when you have a large project and you did not track all changes.

Note that this has nothing to do with binary; I want to remove them from the code.

+3
source share
5 answers

I do not know a single program that exactly matches your needs; but with some neat lateral thinking, you achieve cproto , which does what you need. Just delete the current header file, run cproto to get a new one containing only prototypes, and enter all the necessary macros and typedefs from your preamble.

+2
source

You can use makeheaders to generate header files with the correct list of prototypes and use these headers or cut “cancel” definitions to replace them in existing headers

+1
source

, :

.c .h . .h. .c. undefined. .

+1

, , . doxygen, , . called by , a included by .

doxygen, .

+1

cproto, makeheaders.

: , typedef, (!) .., .

makeheaders are a bit more complicated / smarter, as it will create .h after inclusion in .c, so no other inclusion in .h is required.

+1
source

Source: https://habr.com/ru/post/1772657/


All Articles