Подтвердить что ты не робот

Как настроить .ycm_extra_conf.py для текущего проекта, включите PATH

Я установил YCM и синтаксис для VIM, как правило, они работают нормально, но у меня есть проблема, когда он обнаруживает некоторые ошибки в моем коде, и это показывает, что НЕ может найти некоторые файлы head (это мой файл главы проекта).

Ниже показано мое дерево каталогов:

TOP
├── debug
│   ├── debug.c
│   ├── debug.h
│   ├── debug.mk
│   └── instrument.c
├── driver
│   ├── driver.c
│   ├── driver_ddi.c
│   ├── driver_ddi.h
│   ├── driver.h
│   └── driver.mk
├── include
│   └── common.h
├── libs
├── Makefile
├── mw
│   ├── manager.c
│   └── mw.mk
└── root
    ├── main.c
    └── root.mk

Я скопировал a .ycm_extra_conf.py в TOP, между тем, я также сгенерировал файл tag и cscope в TOP, поэтому каждый раз, когда я открываю файл в TOP, например:

[email protected]:~/Work/c/sample/src
-> gvim ./driver/driver.c

чтобы каждый раз я мог добавлять файлы tag и cscope в VIM. Проблема заключается в том, что если я открываю driver.c, которые содержат файлы head: driver.h, driver_ddi.h, debug.h, common.h, код, как показано ниже:

#include <stdio.h>
#include <stdlib.h>
#include "math.h"
#include "common.h"
#include "debug.h"
#include "driver_ddi.h"
#include "driver.h"

syntastic или YCM всегда показывают, что он НЕ может найти common.h и debug.h, другие файлы заголовков в порядке.

Моя YCM и синтаксическая часть конфигурации в файле vimrc:

" YCM
"   let g:ycm_extra_conf_globlist = ['~/.vim/bundle/YouCompleteMe/cpp/ycm/*','!~/*']
    let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'

" Syntastic
    let g:syntastic_c_checkers=['make']
    let g:syntastic_always_populate_loc_list = 1
    let g:syntastic_check_on_open=1
    let g:syntastic_enable_signs=1
    let g:syntastic_error_symbol = '✗'
    let g:syntastic_warning_symbol = '⚠'
    set statusline+=%#warningmsg#
    set statusline+=%{SyntasticStatuslineFlag()}
    set statusline+=%*gbar

My .ycm_extra_conf.py напишите переменную flags как:

flags = [
'-Wall',
'-Wextra',
'-Werror',
'-Wc++98-compat',
'-Wno-long-long',
'-Wno-variadic-macros',
'-fexceptions',
'-DNDEBUG',
'-std=c99',
# ...and the same thing goes for the magic -x option which specifies the
# language that the files to be compiled are written in. This is mostly
# relevant for c++ headers.
# For a C project, you would set this to 'c' instead of 'c++'.
'-x', #I don't know if I need remove -x
'c',
'-isystem',
'../llvm/include',
'-isystem',
'../llvm/tools/clang/include',
'-I',
'.',
'-I',
'../driver'
'-I',
'../debug'
'-I',
'../include'
'-I',
'../include'
]

любые неправильные флаги, которые я установил?

4b9b3361

Ответ 1

Перемещено здесь из вопроса.

Я нашел проблему:

flags = [
'-Wall',
'-Wextra',
'-Werror',
'-Wc++98-compat',
'-Wno-long-long',
'-Wno-variadic-macros',
'-fexceptions',
'-DNDEBUG',
'-std=c99',
# ...and the same thing goes for the magic -x option which specifies the
# language that the files to be compiled are written in. This is mostly
# relevant for c++ headers.
# For a C project, you would set this to 'c' instead of 'c++'.
'-x', #I don't know if I need remove -x
'c',
'-isystem',
'../llvm/include',
'-isystem',
'../llvm/tools/clang/include',
'-I./driver',
'-I./debug',
'-I./include',
]

Я пропустил запятую, и путь должен быть ./xxx, также neeeeed '-I/usr/include' и '-I/usr/local/include'.