Is there a way to prevent developers from committing code when certain unsafe or obsolete functions are used? For example:
- scanf
- atoi
- gets
- etc..
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A project I’ve worked uses a simple set of macros in a header that’s included in every file (some compilers let you specify such a header on the command line, so you can force it’s use in a makefile):
With these macros, the build will fail if you try to use a banned function (and the linker will tell you what you should use instead).
So it doesn’t get checked on commit, per se, but as long as your team members make sure things build before they check in, the system works. And if they don’t, then everyone starts getting build break emails, which tends to quickly correct the behavior.
Simple, but effective.