开发者

Strong typedef static checker (unix)

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 Enforce strong type checking in C (type strictness for typedefs) and this 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.


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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜