spinclude - A Tarjan Algorithm Implementation for Finding Circular Included Header Files in C/C++ Projects
Circular included headers are dangerous that they can cause linking error while compiling. This tool will help detect those files on the whole project without compiling.
- Supports generating & reading project configuration
- Detects excluding system headers
- Google unit test
- Verbose mode for more detailed report
- C++11 compiler
- Linux system (tested on Ubuntu 16 & Fedora 25)
spinclude [options] [dir1 dir2...]
if [dir1 dir2...] is blank, use current directory as project dir
Option:
-c {cfg file} use project config file
-g generate config file Project.cfg
-v verbose mode
Run on spinclude:
Config data:
--------------------------------------------------------------------------------
Project dir:
/home/user/Projects/spinclude
Exclude dir:
- /usr/include
- /usr/include/linux
- /usr/lib/include
Exclude file:
-- stdio.h
-- stdlib.h
--------------------------------------------------------------------------------
[WARNING] Found duplicates for 12 header basenames
[WARNING] Tossed out 11 nonexisted included header files
[WARNING] Warning code 12 while getting input headers
Processed 59 header files
================================================================================
++ Found 1 circle(s):
"1file1.hpp" "1file2.hpp" "file1.hpp"
================================================================================
Run on Google protobuf:
Config data:
--------------------------------------------------------------------------------
Project dir:
/home/user/Projects/protobuf
Exclude dir:
- /usr/include
- /usr/include/linux
- /usr/lib/include
Exclude file:
-- stdio.h
-- stdlib.h
--------------------------------------------------------------------------------
[WARNING] Found duplicates for 7 header basenames
[WARNING] Tossed out 41 nonexisted included header files
[WARNING] Warning code 12 while getting input headers
Processed 302 header files
================================================================================
-- No circle found
================================================================================
Also, there packed a utility for solving simple input graph, called tarjan-util
Usage: ./tarjan-util [options] [file1 file2...]
Option:
-v verbose mode
Sample file content:
a b c
b d
d e
e b a
That means the graph is a can go to b & c, b can go to d, and so on
- Tarjan algorithm: Wikipedia article, Tutorial
- Coding style: mcastit - multicast test tool