Static analysis of header inclusion in C++

2019-06-07 07:13发布

It seems that often I find that my code when moving either from one linux installation to another or from one unix to another, I find that I've missed including certain header files.

This tends to become annoying when you give the source to someone else expecting them to be able to compile it just fine, only for it to fail because of missing header file includes.

Are there any static analysis tools that can detect headers that should be explicitly included where they're currently seem to be implicitly included? Is there some way to disable this implicit inclusion of header files?

Also I'd like to detect header files that included and may have become redundant through code changes, and are no longer required.

2条回答
甜甜的少女心
2楼-- · 2019-06-07 08:08

I have used checkheaders with some success. Development seems to have slowed down some in the last year, but it is still usable. Probably it's best to use the trunk version.

查看更多
乱世女痞
3楼-- · 2019-06-07 08:08

There is a google project called Include-What-You-Use that might be helpfull. But still it is very complicated to get it done right. And i'm not aware of any other tool that does this.

查看更多
登录 后发表回答