如何为当前项目配置.ycm_extra_conf.py包括PATH

 吴佩珠淑杰 发布于 2023-02-04 22:06

我为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 
#include 
#include "math.h"
#include "common.h"
#include "debug.h"
#include "driver_ddi.h"
#include "driver.h"

syntasticYCM总是显示无法找到common.hdebug.h其他头文件是否正确.

我的YCM和在vimrc文件中的syntastic配置部分:

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

我设置的任何错误标志?

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

    2023-02-04 22:23 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有