Add external tool for Lint software in NBEclipse IDE

Topics for the Eclipse Environment
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: Add external tool for Lint software in NBEclipse IDE

Post by tod »

Let me clarify; the blog post assumes you are using co-gnu3.lnt. I didn't realize that was obsolete until I started using boost. Since making that post I have switched to co-gcc.lnt. I read the top of the co-gcc.mak file and the gcc-readme.txt. My results weren't much better (if any) than using co-gnu3.lnt but if I want help from gimpel tech support I had to go down this path. Here's the steps I took (if memory serves) I created a .bat file with this

Code: Select all

make -f co-gcc.mak ^
	GCC_BIN="m68k-elf-gcc" ^
	GXX_BIN="m68k-elf-g++" ^
	CXXFLAGS="-O2 -falign-functions=4  -gdwarf-2 -Wall -Wno-write-strings -c -fmessage-length=0 -fno-exceptions"
This ends with an error and leaves size-options.lnt blank. My netburner.lnt file specifies size options for si, sp and sl and I suspect that's what this would do. My best guess is it fails because I'm running Win64 and the generated file co-gcc.mak.temp-generate-size-options will only run under 32 bit. Gimpel wasn't any help with any of this. Did you get a size-options.lnt file? If so can you paste the contents here?

So now my netburner.lnt file specifies co-gcc.lnt and the entire file looks like this

Code: Select all


c:\lint\co-gcc.lnt
c:\lint\au-sm123.lnt 
-si4  -sp4  -sl4

-iC:\Nburn\Mod5272
-iC:\Nburn\Mod5272\system
-iC:\Nburn\include

-elib(129)
-elib(10)
-elib(19)

+libclass( foreign )

//For Eclipse, we change output format of messages
-"format=LINT %t%(: %f:%l %) %n %m"
-width(0,0)
The only other change I made was to comment out a line in co-gcc.lnt that was causing me problems:

Code: Select all

//TEG TODO Commented out the next line
//+cpp(.cc,.C)      // extensions for C++ that are commonly used in addition
                  // to the default extensions of .cpp and .cxx
The biggest pain in the butt now is that I can't lint any source file that includes any boost library. It just generates tons of noise. The 2nd biggest problem is I tend to use namespace aliases

Code: Select all

namespace SL=SyncorLibrary;
This too, causes lint a ton of headaches, James Widman at Gimpel tech support says they support namespace aliases but didn't really help me figure out why this wasn't working.

While I have advocated for using Gimpel's lint in the past (and I still use it when I can) my opinion has increasingly become that it's a bigger pain than it's worth. Especially when I consider how seamless a tool like ReSharper is to use for C# code. The amount of setup and configuration that goes into lint is ridiculous. As I'm increasingly using more of the boost library, it's becoming less and less useful.

Unfortunately, I don't know of any better alternatives. I have tried CppCheck and while it is very easy to set up and use, it does very minimal checking compared to lint. Still a lot of people would probably pick up an error/optimization or two if they used it regularly (and I just found out there is now an eclipse plug in.) My hope is that CppCheck will get more comprehensive as time goes on.
vsabino
Posts: 32
Joined: Wed May 14, 2008 8:45 am

Re: Add external tool for Lint software in NBEclipse IDE

Post by vsabino »

Hi Tod,

I agree getting lint to work is a big pain. Fuuny, one of the reasons I purchased PC-Lint was your endorsement on your blog!

Anyway, size-options.lnt is also empty for me. I guess it's because I also use a 64-bit PC.

What about lint_cmac.h and lint_cppmac.h? you don't have these at all?

your new netburner.lnt is much smaller than the one I copied from your blog. why?

I get this error: 48:1: Warning 686: Option '+cpp(.cc,.C)' is suspicious because of 'Upper case characters within extension '.C'; these will match lower case when +fff is on; try -fff'
I guess it's related to what you commented out in co-gcc.lnt?

I' don't use Boost (maybe I should), in fact I had never heard of it before reading your post; but just curious, why does it not work? I thought PC-Lint was a general tool which can work with any piece of C/C++ code. It seems to work with the NetBurner libraries.

Can you also comment on what I mentioned about the Console output limit?

Thanks,
Victor
User avatar
dciliske
Posts: 623
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: Add external tool for Lint software in NBEclipse IDE

Post by dciliske »

Tod,

Now I'm curious (not for including in the main libraries :shock: , just for general knowledge), how's Boost's performance on Netburner boards?
Dan Ciliske
Project Engineer
Netburner, Inc
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: Add external tool for Lint software in NBEclipse IDE

Post by tod »

Dan, Victor - I think I'll start another topic on boost.

Victor, I don't know why you think I don't have the lint_cmac and lint_cppmac, if you're talking about the blog post remember that it's 3 years old and DOESN'T use co-gcc.mak. If I get everything working the way it should I'll write a new blog. But I do have all the files. I suspect I don't need lint_cmac.h since I only do c++ compilation (i.e. __cplusplus is always defined). At any rate co-gcc.lnt has

Code: Select all

-header(co-gcc.h)
which makes lint treat every source file it parses as if it had an #include co-gcc.h at the top. Since co-gcc.h includes lint_cppmac.h it has to be there (I suppose it could be empty) but since it was correctly generated by the .mak file I use it.

The new netburner.lnt is smaller for two reasons. Many of the lines that were in it were specific to my projects (like anything with the word SCPI) and those lines really belong in a project.lnt specific file. Secondly, using co-gcc.lnt instead of co-gnu3.lnt allowed me to get rid of a lot of settings.

If you don't name your c++ source files .C or .cc (and why would you?) you too can comment out that line.

You can increase the size of the console output buffer. Window->Preferences then follow the arrows in the image below. Generally though you want to lint one file at a time. You also want to start with the low-level files you've written that don't include too many other files. Then work your way up. This should limit your errors. You can also supress library errors (-wlib(0) - but Gimpel recommends against doing this). Once you have all your individual files clean (or you've suppressed the errors that cause the bulk of the noise), you can try linting the entire project.

[EditorialRant]Let me also say that depending upon how experienced a C++ programmer you are, lint can make you a much better programmer. It can also find bugs that would take you a long long time to find manually. I don't think I could write const-correct code without it. I just wish the folks at Gimpel would look at how well some of the competing tools work and put some SERIOUS effort into improving their tool. Imagine if lint worked like CppCheck![/EditorialRant]
ConsoleSize.jpg
ConsoleSize.jpg (102.07 KiB) Viewed 7746 times
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: Add external tool for Lint software in NBEclipse IDE

Post by tod »

I feel compelled to mention that I just upgraded from 9.00i to 9.00j and Gimpel's lint seems to have fixed most of the things that were causing me heartache.
1. namespace SL = SyncorLibrary; //now working
2. The BOOST library (I updated to 1.0.53) is generating far fewer errors and adding +linebuf to my project.lnt got rid of many.
3. Boost::FOR_EACH is still problematic so I suppress a handful of errors via my project.lnt using both

Code: Select all

-etemplate(1054)
and a series of -esym(...) commands.
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: Add external tool for Lint software in NBEclipse IDE

Post by tod »

I added a new blog post on Using Lint with GCC and NetBurner, and included links to gist for all the files I use when I lint.
Post Reply