Do you know tool building tree of include files in project\file?

前端 未结 6 1843
臣服心动
臣服心动 2020-12-03 23:59

Say, I\'d like to have a tool (or script?) taking project (or .h file) and building searchable tree of \"includes\" included into it (of included into of included into and s

相关标签:
6条回答
  • 2020-12-04 00:21

    Eclipse CDT has the Include Browser under Window --> Show View --> Other... --> C/C++ --> Include Browser.

    0 讨论(0)
  • 2020-12-04 00:27

    Not entirely sure this is what you're after, but you can easily get a list of includes by generating the post-CPP-processed file from the base c file, and grepping out the file/line number comments, e.g., using gcc

    gcc -E main.c {usual flags} | grep '#' | cut -d' ' -f3 | sort | uniq
    

    where main.c is your base c file.

    0 讨论(0)
  • 2020-12-04 00:35

    Include Finder is a pretty useful tool. It has some bugs, and hasn't been updated in a while, but the author does provide the source, so you can modify it to your liking.

    enter image description here

    0 讨论(0)
  • 2020-12-04 00:41

    If I remember correctly, doxygen can do this.

    0 讨论(0)
  • 2020-12-04 00:43

    There exists a tool called include gardener, which can be found here: https://github.com/feddischson/include_gardener This gives you the include tree in dot or graphml (xml) format. But it does not consider other preprocessor statements like #if, #else, #endif.

    0 讨论(0)
  • 2020-12-04 00:45

    I know this is an old question, a slightly more useful output than the gcc/g++ -E output alone would also used the -H flag (instead or in addition to):

    g++ -H {my -I and other flags} -E -o /dev/null file.cpp

    here is a sample output, tree structure helps figure out who included what as a bonus it also lists at the bottom which files may benefit from an include guard

    . generated/gen-cpp/File.h
    .. /usr/include/thrift/TProcessor.h
    ... /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/string
    .... /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/x86_64-redhat-linux/bits/c++config.h
    ..... /usr/include/bits/wordsize.h
    ..... /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/x86_64-redhat-linux/bits/os_defines.h
    ...... /usr/include/features.h
    ....... /usr/include/sys/cdefs.h
    ........ /usr/include/bits/wordsize.h
    ....... /usr/include/gnu/stubs.h
    ........ /usr/include/bits/wordsize.h
    ........ /usr/include/gnu/stubs-64.h
    ..... /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/x86_64-redhat-linux/bits/cpu_defines.h
    .... /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stringfwd.h
    
    ...
    
    0 讨论(0)
提交回复
热议问题