当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 10 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : gvim中c++编程的不足之处(希望有高人解答)
帖子发表于 : 2008-02-12 9:31 

注册: 2008-01-06 19:58
帖子: 11
送出感谢: 0 次
接收感谢: 0 次
如很多帖子所说现生成tags
我用的命令是:
ctags -R --c++-kinds=+px --fields=+iamKlnzS --extra=+fq --language-force=c++
同样在~/.gvimrc中
let Tlist_Ctags_Cmd='ctags -R --c++-kinds=+px --fields=+iamKlnzS --extra=+fq --language-force=c++'

我的问题是:
首先是taglist的不足
如果你用一个.h文件定义下面的东东
#ifndef _CHECKCLASS_H__INC
#define _CHECKCLASS_H__INC
namespace hello{
class check{
private:
int jj;
protected:
int xiaojj;
public:
int a;
int b;
int c;
public:
check();
void hehe();
void haha();
void hoho();
};
}
#endif
然后再用一个.cpp进行实现
#include "checkclass.h"
#include <iostream>

check::check():a(1),b(2),c(3){};

void check::hehe(){
cout<<"hehe"<<endl;
}

void check::haha(){
cout<<"haha"<<endl;
}

void check::hoho(){
cout<<"hoho"<<endl;
}
这个时候你用Taglist打开taglist浏览上面的.h文件的时候不能看到hehe,haha,hoho等方法和成员,如附件里的taglist图一样,我感觉这是不爽的地方


然后是补全,我用的是omnicppcomplete
#include <iostream>
#include <string>
using namespace std;
using namespace _GLIBCXX_STD;


int main(){
int x=30, y=300, z=1024;
cout<<x<<' '<<y<<' '<<z<<endl;
string a;
a. //这个时候是找不到string的成员的,不能弹出menu
//如果换成下面的代码
basi_string<char> a;
a. //这个时候是完全能找到成员的,能弹出menu
}
原因是stl在定义string的时候用了一个typedef
typedef basic_string<char> string;
这样就导致了omnicppcomplete的失效

以上两个问题不知有高人可以解决?????


附件:
taglist.jpg
taglist.jpg [ 22.57 KiB | 被浏览 1551 次 ]

页首
 用户资料  
 
2 楼 
 文章标题 :
帖子发表于 : 2008-02-12 13:02 
头像

注册: 2006-05-19 9:54
帖子: 1822
地址: Shanghai
送出感谢: 2
接收感谢: 11
这两个其实都不是vim,是ctags的问题

*假定我们用的ctags都是Exuberant Ctags*

问题一貌似无解...?
Exuberant Ctags貌似就是只能从defination抓tag而不是declaration
尝试一下其他ctags的clone或许能行

问题二的话
要看ctags的版本了,vim文档里面也有提到
引用:
For version 5.5.4 you should add a patch that adds the "typename:" field:
ftp://ftp.vim.org/pub/vim/unstable/patc ... .5.4.patch

用新版本的话,应该没有问题了,或者就直接用他那个补丁过的版本


页首
 用户资料  
 
3 楼 
 文章标题 :
帖子发表于 : 2008-02-12 14:24 

注册: 2008-01-06 19:58
帖子: 11
送出感谢: 0 次
接收感谢: 0 次
ctags-exuberant --version
Exuberant Ctags 5.6, Copyright (C) 1996-2004 Darren Hiebert
Compiled: Aug 2 2006, 01:53:15
Addresses: <dhiebert@users.sourceforge.net>, http://ctags.sourceforge.net
Optional compiled features: +wildcards, +regex

这是我的ctags的信息
首先是ctags-exuberant
然后是版本是5.6的

2楼你所说的clone的版本是指哪些???能否告知一二??


页首
 用户资料  
 
4 楼 
 文章标题 :
帖子发表于 : 2008-02-12 14:49 
头像

注册: 2006-05-19 9:54
帖子: 1822
地址: Shanghai
送出感谢: 2
接收感谢: 11
5.6的话,看一下生成的tags文件里面有没有 typename 这一项?

Exuberant ctags本身就是一个ctags的clone,只不过实在太常用,导致其他ctags反而不知名了
稍微搜了一下,etags,elvis的ctags好像有从defination抓tag的功能,具体当然是没有试过

或许lz有兴趣帮Exuberant ctags加上这个功能 :D


页首
 用户资料  
 
5 楼 
 文章标题 :
帖子发表于 : 2008-02-12 15:02 

注册: 2008-01-06 19:58
帖子: 11
送出感谢: 0 次
接收感谢: 0 次
还有我不觉得是ctags的问题,我觉得是taglist的问题我把我生成的tag文件帖出来
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.6 //
_CHECKCLASS_H__INC checkclass.h 21;" kind:macro line:21 language:C++
a checkclass.h 29;" kind:member line:29 language:C++ class:hello::check access:public
a main.cpp 22;" kind:local line:22 language:C++
b checkclass.h 30;" kind:member line:30 language:C++ class:hello::check access:public
c checkclass.h 31;" kind:member line:31 language:C++ class:hello::check access:public
check checkclass.cpp 22;" kind:function line:22 language:C++ class:check signature:()
check checkclass.h 23;" kind:class line:23 language:C++ namespace:hello
check checkclass.h 33;" kind:prototype line:33 language:C++ class:hello::check access:public signature:()
check::check checkclass.cpp 22;" kind:function line:22 language:C++ class:check signature:()
check::hehe checkclass.cpp 24;" kind:function line:24 language:C++ class:check signature:()
checkclass.cpp checkclass.cpp 1;" kind:file line:1 language:C++
checkclass.h checkclass.h 1;" kind:file line:1 language:C++
cout.cpp cout.cpp 1;" kind:file line:1 language:C++
haha checkclass.h 35;" kind:prototype line:35 language:C++ class:hello::check access:public signature:()
hehe checkclass.cpp 24;" kind:function line:24 language:C++ class:check signature:()
hehe checkclass.h 34;" kind:prototype line:34 language:C++ class:hello::check access:public signature:()
hello checkclass.h 22;" kind:namespace line:22 language:C++
hello::check checkclass.h 23;" kind:class line:23 language:C++ namespace:hello
hello::check::a checkclass.h 29;" kind:member line:29 language:C++ class:hello::check access:public
hello::check::b checkclass.h 30;" kind:member line:30 language:C++ class:hello::check access:public
hello::check::c checkclass.h 31;" kind:member line:31 language:C++ class:hello::check access:public
hello::check::check checkclass.h 33;" kind:prototype line:33 language:C++ class:hello::check access:public signature:()
hello::check::haha checkclass.h 35;" kind:prototype line:35 language:C++ class:hello::check access:public signature:()
hello::check::hehe checkclass.h 34;" kind:prototype line:34 language:C++ class:hello::check access:public signature:()
hello::check::hoho checkclass.h 36;" kind:prototype line:36 language:C++ class:hello::check access:public signature:()
hello::check::jj checkclass.h 25;" kind:member line:25 language:C++ class:hello::check access:private
hello::check::xiaojj checkclass.h 27;" kind:member line:27 language:C++ class:hello::check access:protected
hoho checkclass.h 36;" kind:prototype line:36 language:C++ class:hello::check access:public signature:()
jj checkclass.h 25;" kind:member line:25 language:C++ class:hello::check access:private
main cout.cpp 26;" kind:function line:26 language:C++ signature:()
main main.cpp 21;" kind:function line:21 language:C++ signature:()
main.cpp main.cpp 1;" kind:file line:1 language:C++
x cout.cpp 27;" kind:local line:27 language:C++
xiaojj checkclass.h 27;" kind:member line:27 language:C++ class:hello::check access:protected
y cout.cpp 27;" kind:local line:27 language:C++
z cout.cpp 27;" kind:local line:27 language:C++
tag文件生成得很完整,但是taglist并没有完整的显示tag里面的列容


页首
 用户资料  
 
6 楼 
 文章标题 :
帖子发表于 : 2008-02-12 16:50 
头像

注册: 2006-05-19 9:54
帖子: 1822
地址: Shanghai
送出感谢: 2
接收感谢: 11
你有一个基本问题没搞清,taglist使用的tag是他自己生成的,而不是你在外面生成的tags文件
let Tlist_Ctags_Cmd 只是用来设置命令位置,而不是用来设置参数的
事实上,ctags执行中会自动加入很多参数,结果就是,那些declaration并没有被taglist调用的ctags显示出来

或许问题1的答案应该纠正成这样,taglist不支持这样的功能。


页首
 用户资料  
 
7 楼 
 文章标题 :
帖子发表于 : 2008-02-12 22:15 

注册: 2008-01-06 19:58
帖子: 11
送出感谢: 0 次
接收感谢: 0 次
Strange 写道:
你有一个基本问题没搞清,taglist使用的tag是他自己生成的,而不是你在外面生成的tags文件
let Tlist_Ctags_Cmd 只是用来设置命令位置,而不是用来设置参数的
事实上,ctags执行中会自动加入很多参数,结果就是,那些declaration并没有被taglist调用的ctags显示出来

或许问题1的答案应该纠正成这样,taglist不支持这样的功能。


确实是如你说的一样,这个是taglist不支持………………

但是还有一个问题也是让我不甘心的地方,那就是typedef的问题
上面的.h和.cpp文件照旧不变,现在我加一个checktype.h文件,里面自己定义了一个typedef

#ifndef _CHECKTYPE_H__INC
#define _CHECKTYPE_H__INC
#include "xxxx.h" //class check的头文件
typedef check mycheck;
#endif /* ----- #ifndef _CHECKTYPE_H__INC ----- */

然后主cpp:
#include "checktype.h"

int main(){
mycheck a;
a. //这个时候还是不能进行补全,omnicppcomplete告知不知道补全模式,不知道你的是不是这样??
}

我生成的tag文件里面却有这个typedef,如下:
!#ifndef _CHECKTYPE_H__INC
#define _CHECKTYPE_H__INC
typedef check mycheck;
#endif /* ----- #ifndef _CHECKTYPE_H__INC ----- */_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.6 //
.checkclass.cpp.swp .checkclass.cpp.swp 1;" kind:file line:1 language:C++
.checkclass.h.swp .checkclass.h.swp 1;" kind:file line:1 language:C++
.checktags.swp .checktags.swp 1;" kind:file line:1 language:C++
.checktype.h.swp .checktype.h.swp 1;" kind:file line:1 language:C++
.cout.cpp.swp .cout.cpp.swp 1;" kind:file line:1 language:C++
.main.cpp.swp .main.cpp.swp 1;" kind:file line:1 language:C++
_CHECKCLASS_H__INC checkclass.h 21;" kind:macro line:21 language:C++
_CHECKTYPE_H__INC checktype.h 21;" kind:macro line:21 language:C++
a checkclass.h 29;" kind:member line:29 language:C++ class:hello::check access:public
a main.cpp 23;" kind:local line:23 language:C++
b checkclass.h 30;" kind:member line:30 language:C++ class:hello::check access:public
c checkclass.h 31;" kind:member line:31 language:C++ class:hello::check access:public
check checkclass.cpp 22;" kind:function line:22 language:C++ class:check signature:()
check checkclass.h 23;" kind:class line:23 language:C++ namespace:hello
check checkclass.h 33;" kind:prototype line:33 language:C++ class:hello::check access:public signature:()
check::check checkclass.cpp 22;" kind:function line:22 language:C++ class:check signature:()
check::hehe checkclass.cpp 24;" kind:function line:24 language:C++ class:check signature:()
checkclass.cpp checkclass.cpp 1;" kind:file line:1 language:C++
checkclass.h checkclass.h 1;" kind:file line:1 language:C++
checktags checktags 1;" kind:file line:1 language:C++
checktype.h checktype.h 1;" kind:file line:1 language:C++
cout.cpp cout.cpp 1;" kind:file line:1 language:C++
cppcomplete.tags cppcomplete.tags 1;" kind:file line:1 language:C++
format checktags 1;" kind:variable line:1 language:C++
format cppcomplete.tags 1;" kind:variable line:1 language:C++
format jjtags 1;" kind:variable line:1 language:C++
format xinjjtags 1;" kind:variable line:1 language:C++
haha checkclass.h 35;" kind:prototype line:35 language:C++ class:hello::check access:public signature:()
hehe checkclass.cpp 24;" kind:function line:24 language:C++ class:check signature:()
hehe checkclass.h 34;" kind:prototype line:34 language:C++ class:hello::check access:public signature:()
hello checkclass.h 22;" kind:namespace line:22 language:C++
hello::check checkclass.h 23;" kind:class line:23 language:C++ namespace:hello
hello::check::a checkclass.h 29;" kind:member line:29 language:C++ class:hello::check access:public
hello::check::b checkclass.h 30;" kind:member line:30 language:C++ class:hello::check access:public
hello::check::c checkclass.h 31;" kind:member line:31 language:C++ class:hello::check access:public
hello::check::check checkclass.h 33;" kind:prototype line:33 language:C++ class:hello::check access:public signature:()
hello::check::haha checkclass.h 35;" kind:prototype line:35 language:C++ class:hello::check access:public signature:()
hello::check::hehe checkclass.h 34;" kind:prototype line:34 language:C++ class:hello::check access:public signature:()
hello::check::hoho checkclass.h 36;" kind:prototype line:36 language:C++ class:hello::check access:public signature:()
hello::check::jj checkclass.h 25;" kind:member line:25 language:C++ class:hello::check access:private
hello::check::xiaojj checkclass.h 27;" kind:member line:27 language:C++ class:hello::check access:protected
hoho checkclass.h 36;" kind:prototype line:36 language:C++ class:hello::check access:public signature:()
jj checkclass.h 25;" kind:member line:25 language:C++ class:hello::check access:private
jjtags .checktags.swp 8;" kind:variable line:8 language:C++
jjtags jjtags 1;" kind:file line:1 language:C++
main cout.cpp 26;" kind:function line:26 language:C++ signature:()
main main.cpp 22;" kind:function line:22 language:C++ signature:()
main.cpp main.cpp 1;" kind:file line:1 language:C++
mycheck checktype.h 23;" kind:typedef line:23 language:C++
x cout.cpp 27;" kind:local line:27 language:C++
xiaojj checkclass.h 27;" kind:member line:27 language:C++ class:hello::check access:protected
xinjjtags checktags 10;" kind:variable line:10 language:C++
xinjjtags xinjjtags 1;" kind:file line:1 language:C++
y cout.cpp 27;" kind:local line:27 language:C++
z cout.cpp 27;" kind:local line:27 language:C++


页首
 用户资料  
 
8 楼 
 文章标题 :
帖子发表于 : 2008-02-13 9:46 
头像

注册: 2006-05-19 9:54
帖子: 1822
地址: Shanghai
送出感谢: 2
接收感谢: 11
checktype.h连namespace都没有,怎么叫ctags抓tag啊...
还有,顺便升级ctags到5.7吧


页首
 用户资料  
 
9 楼 
 文章标题 :
帖子发表于 : 2008-02-13 11:04 

注册: 2008-01-06 19:58
帖子: 11
送出感谢: 0 次
接收感谢: 0 次
好了好了!!!!!!
这下好了!!!!!!!!!

确实是我自己不小心!!!!!!
strange,非常感谢你!!!!!!!!!!!谢谢你这么有耐心!!!!!!!!谢谢!!!!!!!!


页首
 用户资料  
 
10 楼 
 文章标题 : Re: gvim中c++编程的不足之处(希望有高人解答)
帖子发表于 : 2009-04-03 23:03 
头像

注册: 2009-02-22 14:15
帖子: 173
送出感谢: 0 次
接收感谢: 0 次
学习了.


_________________
Desire Freedom, Love Beauty, Keep Hacking。


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 10 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 1 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译