Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove unused function protypes from .h file

Tags:

c

header-files

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 look for the prototypes that are not in the .c file and automatically remove them.

This is really useful for source code cleaning purposes when you have a big project and you did not keep track of all the changes.

Note that the it does not have anything to do with the binary, I want to remove them from the code.

like image 402
skd Avatar asked Sep 12 '25 11:09

skd


2 Answers

I don't know of any program that fits your need exactly; but with some neat lateral thinking, you arrive at cproto, which sort of does what you need. Just remove the current header file, run cproto to get a new one only containing the relevant prototypes, and put in whatever macros and typedefs you need from your preamble.

like image 99
Williham Totland Avatar answered Sep 15 '25 05:09

Williham Totland


You could use makeheaders to generate header files with the correct list of prototypes in and either use those headers, or cut'n'paste the definitions to replace the ones in your existing headers

like image 28
The Archetypal Paul Avatar answered Sep 15 '25 06:09

The Archetypal Paul