gpt4 book ai didi

c - 如何为当前项目配置 .ycm_extra_conf.py include PATH

转载 作者:太空狗 更新时间:2023-10-29 16:39:01 32 4
gpt4 key购买 nike

我为 VIM 安装了 YCM 和 syntastic,通常它们工作正常,但是当它检测到我的代码中的一些错误时我遇到了问题,它显示找不到一些头文件(这是我的项目头文件)。

我的目录树如下所示:

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

我复制了一个.ycm_extra_conf.py到TOP,同时我也会在TOP生成tagcscope文件,因此每次我在 TOP 上打开文件时,例如:

howchen@host:~/Work/c/sample/src
-> gvim ./driver/driver.c

确保每次我都可以在 VIM 中添加 tagcscope 文件。问题是,如果我打开driver.c,里面有头文件: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"

syntasticYCM总是显示找不到common.hdebug.h,其他头文件没问题。

vimrc 文件中我的 YCM 和合成配置部分:

" 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

我的 .ycm_extra_conf.pyflags 变量写为:

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'
]

我是否设置了错误的标记?

最佳答案

从问题移到这里。

我发现了问题:

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,还需要 '-I/usr/include''-I/usr/本地/包含'

关于c - 如何为当前项目配置 .ycm_extra_conf.py include PATH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21014105/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com