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.

6 comments on “Installing Splint on Mac OSX
  1. 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

  2. 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”
    ^

  3. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *