Installing Splint on Mac OSX

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.

  1. Download the source from http://www.splint.org/downloads/splint-3.1.2.src.tgz
  2. Open the .tgz file by double clicking.
  3. Open a terminal window and cd to the splint-3.1.2 folder
  4. Configure by using sudo ./configure and enter your password
  5. Open the osd.c file using nano src/osd.c
  6. 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).
  7. 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.