| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1730 人关注过本帖
标题:用vecto做三维向量产生warning,不知哪里的问题
只看楼主 加入收藏
naughtyboy
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2006-8-5
收藏
 问题点数:0 回复次数:13 
用vecto做三维向量产生warning,不知哪里的问题
我用vector做三维向量 ,然后用typedef 自己命了一个别名。
build时产生不明原因的warning 而且之后 只要使用这个别名,就会产生更多的warning。
我自己分析了一下后,把代码简化到了如下,但问题warning依然存在,请大家看看是怎么回事,谢谢。

代码:

#include<vector>
using namespace std;
class A{
public:
A(){};
};
typedef vector<vector<vector<A> > > Space;
void main()
{
Space kkk;
}

//////////////////////////////////
warning 如下:

Compiling...
vectorTest.cpp
E:\Program Files\Microsoft Visual Studio\MyProjects\pqjunior\test\vectorTest.cpp(11) : warning C4786: 'std::reverse_iterator<std::vector<std::vector<A,std::allocator<A> >,std::allocator<std::vector<A,std::allocator<A> > > > const *,std::vector<std::
vector<A,std::allocator<A> >,std::allocator<std::vector<A,std::allocator<A> > > >,std::vector<std::vector<A,std::allocator<A> >,std::allocator<std::vector<A,std::allocator<A> > > > const &,std::vector<std::vector<A,std::allocator<A> >,std::allocator
<std::vector<A,std::allocator<A> > > > const *,int>' : identifier was truncated to '255' characters in the debug information
E:\Program Files\Microsoft Visual Studio\MyProjects\pqjunior\test\vectorTest.cpp(11) : warning C4786: 'std::reverse_iterator<std::vector<std::vector<A,std::allocator<A> >,std::allocator<std::vector<A,std::allocator<A> > > > *,std::vector<std::vector
<A,std::allocator<A> >,std::allocator<std::vector<A,std::allocator<A> > > >,std::vector<std::vector<A,std::allocator<A> >,std::allocator<std::vector<A,std::allocator<A> > > > &,std::vector<std::vector<A,std::allocator<A> >,std::allocator<std::vector
<A,std::allocator<A> > > > *,int>' : identifier was truncated to '255' characters in the debug information
e:\program files\microsoft visual studio\vc98\include\vector(39) : warning C4786: 'std::vector<std::vector<std::vector<A,std::allocator<A> >,std::allocator<std::vector<A,std::allocator<A> > > >,std::allocator<std::vector<std::vector<A,std::allocator
<A> >,std::allocator<std::vector<A,std::allocator<A> > > > > >::vector<std::vector<std::vector<A,std::allocator<A> >,std::allocator<std::vector<A,std::allocator<A> > > >,std::allocator<std::vector<std::vector<A,std::allocator<A> >,std::allocator<std
::vector<A,std::allocator<A> > > > > >' : identifier was truncated to '255' characters in the debug information
e:\program files\microsoft visual studio\vc98\include\vector(60) : warning C4786: 'std::vector<std::vector<std::vector<A,std::allocator<A> >,std::allocator<std::vector<A,std::allocator<A> > > >,std::allocator<std::vector<std::vector<A,std::allocator
<A> >,std::allocator<std::vector<A,std::allocator<A> > > > > >::~vector<std::vector<std::vector<A,std::allocator<A> >,std::allocator<std::vector<A,std::allocator<A> > > >,std::allocator<std::vector<std::vector<A,std::allocator<A> >,std::allocator<st
d::vector<A,std::allocator<A> > > > > >' : identifier was truncated to '255' characters in the debug information
Linking...

test.exe - 0 error(s), 4 warning(s)

注:我用的是vc 所以第一遍build 会报告warning ,但紧接着再按一次build 就不会显示warning 了.
这时候,只要作小改动(比如加一个空格), 再build ,就会出现相同的 warning.
搜索更多相关主题的帖子: warning 三维 向量 vector 别名 
2006-10-02 15:00
chenchao
Rank: 1
等 级:新手上路
帖 子:45
专家分:0
注 册:2006-5-20
收藏
得分:0 
何不尝试用valarray的切割来构造多维向量!!!
2006-10-03 11:02
wangxiang
Rank: 2
等 级:新手上路
威 望:5
帖 子:376
专家分:0
注 册:2006-3-28
收藏
得分:0 

点 工程--设置---C/C++ -- (分类)C++Language


2006-10-03 13:36
naughtyboy
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2006-8-5
收藏
得分:0 
谢谢帮忙,不过:

设置成c++ Language 似乎还是没有用啊?而且,这个选项是干什么的?
valarray 怎么用?


2006-10-04 11:05
wangxiang
Rank: 2
等 级:新手上路
威 望:5
帖 子:376
专家分:0
注 册:2006-3-28
收藏
得分:0 

我设置了就可以,你的我就不知道了


2006-10-04 22:20
naughtyboy
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2006-8-5
收藏
得分:0 
大概知道是怎么回事了:
vector 在声明时有很多的默认参数。而用三重嵌套时这个 vector的定义就会很长 为:
std::reverse_iterator<std::vector<std::vector<A,std::allocator<A> >,std::allocator<std::vector<A,std::allocator<A> > > > const *,std::vector<std::vector<A,std::allocator<A> >,std::allocator<std::vector<A,std::allocator<A> > > >,std::vector<std::vector<A,std::allocator<A> >,std::allocator<std::vector<A,std::allocator<A> > > > const &,std::vector<std::vector<A,std::allocator<A> >,std::allocator
<std::vector<A,std::allocator<A> > > > const *,int>

可能会导致 编译时的溢出。 于是 : identifier was truncated to '255' characters in the debug information

可是,现在还是不知道怎么样才能使得 那个爆长的定义名 不会溢出呢?

2006-10-08 21:02
wangxiang
Rank: 2
等 级:新手上路
威 望:5
帖 子:376
专家分:0
注 册:2006-3-28
收藏
得分:0 
不是吧,为什么我今天用3楼 的方法还是可以呢
我这个方法是在VC6.0环境中的

2006-10-08 22:06
wfpb
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:2188
专家分:0
注 册:2006-4-2
收藏
得分:0 
呵呵,那你就把那些iterator和allocator换个名字吧。

似乎可以
using namespace std;

定义自己的泛型参数。
template<class T>
class al:public alloctor<T>
{
//加几个泛型的typedef.
};空类就可以了吧。

[glow=255,red,2]wfpb的部落格[/glow] 学习成为生活的重要组成部分!
2006-10-08 23:16
wangxiang
Rank: 2
等 级:新手上路
威 望:5
帖 子:376
专家分:0
注 册:2006-3-28
收藏
得分:0 
把void main()改成int main(){................; return 0;}试试

2006-10-09 11:27
wangxiang
Rank: 2
等 级:新手上路
威 望:5
帖 子:376
专家分:0
注 册:2006-3-28
收藏
得分:0 
把void main()改成int main(){................; return 0;}试试

2006-10-09 11:27
快速回复:用vecto做三维向量产生warning,不知哪里的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013128 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved