Feb 12, 2013

Using Lint with GCC and NetBurner

In a previous article on using Gimpel's PC-lint in Eclipse, I gave examples of setting up lint using the co‑gnu3.lnt file as a starting point. It turns out that particular file is no longer in vogue. The preferred choice for GCC compilers is co-gcc.lnt. Unfortunately, using this version requires that you take some steps to create additional files to make it operate properly.

If you want to create these files yourself from scratch, you'll need to read the gcc-readme.txt file and the comments at the top of the co-gcc.mak file. Also, if like me, you happen to have minGW installed you might have to adjust your path environment variable to remove the paths to


so that the NetBurner paths are used when running the recommended make files. I created a small .bat file with this content:

make -f co-gcc.mak ^
    GCC_BIN='m68k-elf-gcc' ^
    CXXFLAGS='-O2 -falign-functions=4'

I then ran that file from a command prompt in a folder that also has  the co-gcc.mak file provided by Gimpel.  It ends with an error and fails to generate the proper size-options.lnt file but it does generate the required  lint_cmac.h, lint_cppmac.h and gcc-include-path.lnt files.  If you run this yourself your files may vary, but I don't see anything module specific in the results. The files just create GCC specific settings.  I made one modification to the co-gcc.lnt file. Around line 38 you'll find  +cpp (.cc, .C) which tells lint to treat files with those suffixes as C++ files. It was causing errors for me and since I don't use those suffixes I just commented it out.

I put up on gist the full set of files that  I created for linting NetBurner programs. Clicking each link will take you directly to the contents of that file.

I also needed to add a few settings to my project.lnt file to reduce the false positives from using the boost C++ libraries.

About Me

My photo
Tod Gentille (@todgentille) is now a Curriculum Director for Pluralsight. He's been programming professionally since well before you were born and was a software consultant for most of his career. He's also a father, husband, drummer, and windsurfer. He wants to be a guitar player but he just hasn't got the chops for it.