views:

88

answers:

2

Is there a free tool (some kind of a static checker) that does typedef-based type-checking for a plain C (not C++) and runs on Linux (or any kind of free Unix)? I am aware of a commercial one: PC-lint/FlexeLint. It does exactly what I want, but it's not free and Windows-only. Here is an example from it's manual:

typedef int Count;
typedef int Bool;
Count n;
Bool stop;
.
.
.
n = stop ; // tool generates a warning here

I've already read this http://stackoverflow.com/questions/376452/enforce-strong-type-checking-in-c-type-strictness-for-typedefs and this http://stackoverflow.com/questions/3140035/is-there-a-good-way-to-force-type-incompatibility-in-c and I'm aware of the struct encapsulation hack, but that's not what I want. I have a pile of code and I want to check it for this particular type of mistakes.

A: 

What about splint? (I have not checked whether it can do what you want. I doubt it will though.)

Or alternatively, what about using C99's stdbool.h and bool type?

wilx
Thanks for the quick reply :)I've already looked on splint. This is actually the first tool I checked. I ran it in -strict mode on my example and from it's point of view everything was clean.. Additionally, I looked through it's manual and checked every flag in 'Types' section but I wasn't able to find anything useful to me.Regarding the bool, it's just the example from that $$$ windoze PC-lint manual. The actual code deals with ints and longs, no bools.
Paul Fisher
A: 

"lint" was originally a unix tool - is it no longer included in standard distros?

If not, gcc -wall supposedly gives most of the same warnings.

AShelly
No, the equivalent tool is "splint". Splint can't do C99, and see wilx's answer and comments for that.
detly