Company policy dictates that every function in C source code has a prototype. I inherited a project with its own make system (so I cannot test it on gcc or Visual Studio) and found that one of the files has some static functions declared without prototypes. Is there a way (not necessarily with a compiler) to list all functions without prototypes in all .c files?
gcc has an option to warn you about this:
gcc -Wmissing-prototypes
You can turn this warning into an error to stop compilation and force people to fix it:
gcc -Werror=missing-prototypes
If you just want to list it you can compile with the gcc
option -Wmissing-prototypes
and grep for no previous prototype for in the log.
Update based on edit:
Since you now mention that you can't use gcc, you'll have to find a similar option for your current compiler. Most compilers have such an option. Start with the man page or the built in help output.
ctags
can do that!
--c-kinds=p
generates the list of all function prototypes
--c-kinds=f
generates the list of all function definitions
Now you just need to compare those.
diff -u <(ctags -R -x --sort=yes --c-kinds=f | cut -d' ' -f1) <(ctags -R -x --sort=yes --c-kinds=p | cut -d' ' -f1) | sed -n 's/^-//p'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With