How do I download and install lint?
Asked Answered
C

2

20

Does anyone know how to obtain lint for Mac, Windows, and Linux? sudo port install lint can't find it.

Canara answered 30/7, 2011 at 5:25 Comment(5)
Lint is pretty old, and pretty much everything lint used to warn about is now covered by actual compiler warnings. You might want to try something modern like Cppcheck (which works great for C programs too).Beckner
You may need to enable optimizations to get "pretty much everything lint used to warn about'. Without optimizations, the compiler may skip the analysis that would discover the issues it can warn about.Bonni
@GregHewgill, Is Cppcheck available only on Windows? If yes, any suggested alternatives for linux?Husband
@Gokul_uf: Of course not, just download the source tarball from sourceforge or clone the project from github. Cppcheck works on pretty much any platform that can compile C++ code.Beckner
@Husband sudo apt-get install cppcheckSedulous
D
4

From the splint FAQ:

Splint supports most, but not all, of the C99 extensions to the ANSI C.

This implies that splint is alas not the same as lint. I've had personal experience with running splint on pieces of code like this:

for (int i; i < 100; i++)
    /* Run code */

As declaration of a variable inside the for loop header is not permitted until C99, like in this example, splint will complain about this. Hence, I'm still looking for a good alternative to splint for Ubuntu.

Duration answered 12/9, 2013 at 6:49 Comment(3)
should it be for (int i=0; i < 100; i++) /* Run code */Sedulous
@Sedulous For the sake of the example and to avoid confusion, the definition should be omitted here in my opinion. It's the variable declaration that is the issue.Duration
@Sedulous for completition, the code should be: c { int i; for (i = 0; i < 100; i++); } Soubise
C
12

I've only seen lint for BSD. There's splint, however, a GPL lint rewrite, and it's available on most Linux distributions.

Cutthroat answered 30/7, 2011 at 5:34 Comment(1)
On Mavericks, splint complains about osd.c:519:3: error: unknown type name '__pid_t'; did you mean 'pid_t'? __pid_t pid = getpid (); ^~~~~~~ pid_t /usr/include/sys/_types/_pid_t.h:30:31: note: 'pid_t' declared here typedef __darwin_pid_t pid_t; ^ 1 error generated. during compilation/make step. Change that line to pid_t pid = getpid (); to compile/make on OS X Mavericks.Ijssel
D
4

From the splint FAQ:

Splint supports most, but not all, of the C99 extensions to the ANSI C.

This implies that splint is alas not the same as lint. I've had personal experience with running splint on pieces of code like this:

for (int i; i < 100; i++)
    /* Run code */

As declaration of a variable inside the for loop header is not permitted until C99, like in this example, splint will complain about this. Hence, I'm still looking for a good alternative to splint for Ubuntu.

Duration answered 12/9, 2013 at 6:49 Comment(3)
should it be for (int i=0; i < 100; i++) /* Run code */Sedulous
@Sedulous For the sake of the example and to avoid confusion, the definition should be omitted here in my opinion. It's the variable declaration that is the issue.Duration
@Sedulous for completition, the code should be: c { int i; for (i = 0; i < 100; i++); } Soubise

© 2022 - 2024 — McMap. All rights reserved.