.clang_complete at his root, containing the compiler options
Compiler options better to have one option per line
doesn't need to specify any of linker arguments in .clang_complete file
环境:ubuntu10.04.vim7.3
qt编译目录为:/work/GUI/opt/qt-everywhere_embedded_opensource-src-4.8.4
.
按照说明文档和参考网上的资料:
1、在工程根目录下建立.clang_complete
内容:-include-pch pch.pch -fgnu-runtime
2、也新建一个pch.h文件:包含头文件pch.h
//to assign the dependent head file
#include<iostream>#include<vector>
#include<string>#include <QApplication>
#include <QDialog>#include <QLabel>
#include <QTextCodec>#include <QFont>
3、执行命令,我把它放在pch.sh中,省得每次敲
#!/bin/sh#execute thsi script to speed up the complete clang -x c++-header ./pch.h -fno-exceptions -fnu-runtime -o ./pch.pch
4、在.vimrc中配置clang_complete
"setting for the clang_complete plugin ."
let g:clang_complete_auto = 1
let g:clang_complete_copen = 1
let g:clang_complete_quickfix= 0
let g:clang_snippets=1
let g:clang_close_preview=1"set sources for user options passed to clang
let g:clang_auto_user_options = 'path,./.clang_complete,-I/work/GUI/opt/qt-everywhere_embedded_opensource-src-4.8.4/include/'
let g:clang_complete_macros=1
let g:clang_hl_errors=1
let g:clang_complete_patterns=1
5、配置就是如上,执行pch.sh,提示QApplication找不到,应该是没有指定路径导致的。难道我在.vimrc中指定了路径不行吗??
究竟应该怎么处理才可以正确补全,深夜求解了。。
如果可以的话,可以详细一点吗,被他折磨要爆啦。。
clang_complete究竟怎么弄啊,郁闷几天,还是高不赢啊?
-
- 帖子: 16
- 注册时间: 2011-11-05 14:38
-
- 帖子: 157
- 注册时间: 2010-11-11 18:13
- 系统: Ubuntu
Re: clang_complete究竟怎么弄啊,郁闷几天,还是高不赢啊?
有libclang干嘛还用pch呢?
装上libclang然后在.vimrc里面用
那些pch都不需要了.
你可以先试试在非qt的cpp中能不能补全,比如vector. 要注意的是无法编译的文件用clang可能补全不了.
要在qt下用的话,我是用 .clang_complete 文件来实现的
这个文件可以这么生成:
装上libclang然后在.vimrc里面用
代码: 全选
let g:clang_use_library=1
代码: 全选
*clang_complete-use_library*
*g:clang_use_library*
Instead of calling the clang/clang++ tool use libclang directly. This gives
access to many more clang features. Furthermore it automatically caches all
includes in memory. Updates after changes in the same file will therefore be a
lot faster.
你可以先试试在非qt的cpp中能不能补全,比如vector. 要注意的是无法编译的文件用clang可能补全不了.
要在qt下用的话,我是用 .clang_complete 文件来实现的
这个文件可以这么生成:
- 先在qt项目下用qmake生成可用的Makefile
- 在qt目录下用以下命令自动生成 .clang_complete (cc_args.py所在的目录可能与你安装clang_complete的方式有关)
代码: 全选
make CC='~/.vim/bin/cc_args.py gcc' CXX='~/.vim/bin/cc_args.py g++' -B
- .clang_complete 不会被自动载入,最好是把vim退了重开
- 貌似一个文件里面没有函数定义的话可能会导致clang无法补全