Including header files recursively for syntastic

后端 未结 2 1600
眼角桃花
眼角桃花 2021-01-30 15:01

I\'m working with a C++ project and trying to configure it to use syntastic. In my project I have a nested directory structure of header files (The actual nested structure is mu

相关标签:
2条回答
  • 2021-01-30 15:20

    I've had the same question with little luck. However, I've found that if I use the quotation mark style header includes, syntactic will appropriately check the folders and not issue warnings. For example, if you're working on foo2.cpp,

    #include "dir3/foo4.h"
    #include "../dir1/foo1.h"
    

    Save bracket includes for standard libs and any libs you feel like hardcoding into vim.

    0 讨论(0)
  • 2021-01-30 15:28

    You can include all the directories to be searched for header files per project in the project root directory in a file .syntastic_cpp_config. The format for doing so would the same as providing the -I directives to the compiler.

    For your case it means:

    • Create a file .syntastic_cpp_config under sources (assuming that's where your code is and sources is at a same depth level in the directory hierarchy as libs).
    • Put the following lines in it:

      -Ilibs/dir1

      -Ilibs/dir2

      -Ilibs/dir2/dir3

    • Note the the flags are 1 per line.

    • This way you don't have to have all the include directories in your .vimrc.

    You can have a different file to hold this custom configuration per project, specified by the .vimrc global variable g:syntastic_cpp_config_file, eg

    let g:syntastic_cpp_config_file = '.my_custom_include_file_for_syntastic'
    

    Syntastic will check each source directory and upwards until it finds this file and then use it for producing its output.

    See the Syntastic wiki page, Old link for more details.

    0 讨论(0)
提交回复
热议问题