Splint is a really useful utility to check your source code, but it doesn’t seem to be installed by default on MacOS X. It is not too difficult to download the source and install except for the minor issue that it doesn’t build. The good news is it doesn’t take much to fix the build problem. Here are the instructions.
- Download the source from http://www.splint.org/downloads/splint-3.1.2.src.tgz
- Open the .tgz file by double clicking.
- Open a terminal window and cd to the splint-3.1.2 folder
- Configure by using sudo ./configure and enter your password
- Open the osd.c file using nano src/osd.c
- Scroll down to around line 500 and change the line __pid_t pid = getpid (); to pid_t pid = getpid (); then save the file (control-x).
- Type sudo make install to install splint
You should now be able to use splint (eg splint foo.c) and have a look at how many little issues are in your code :) It will fail a few of the tests, but it appears to still work.
Edit Sept 2017. This is a pretty old post. My advice is use brew to install splint.
Thanks for posting this. version 3.1.1 did not install for me – aclocal error.
This one installed fine.
./configure
make
sudo make install
so far install looks good – thanks
Unable to install, while giving make install command, it gives error
Headers/flag_codes.h:22:11: fatal error: ‘flag_codes.gen’ file not found
# include “flag_codes.gen”
^
Hi Romit
You need to use “sudo” now (at least on 10.10). I will update the post.
Works like a charm! Thanks
On my MacBook Air operating Yosemite, after following Daniel’s instructions up to the command sudo make install, I got the same error message as Romit
Headers/flag_codes.h:22:11: fatal error: ‘flag_codes.gen’ file not found
# include “flag_codes.gen”
My directory gcc-3.1.2/src contains the file flag_codes.h but not flag_codes.gen
I’d be grateful for any advice.
This is a pretty old post. My suggestion is to use brew and install splint that way.