免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1311 | 回复: 7
打印 上一主题 下一主题

请高手指点,程序错在那里,该怎么改,十分感谢! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-11-16 22:12 |只看该作者 |倒序浏览
编译一个VOCAL公司的源代码时,提示出错,已试过将加入#include <iterator>,将using namespace Vocal改为using namespace std;或者同时使用std,Vocal,结果是一样,说变量未声明,似乎没有一点作用,请高手帮忙看看,谢谢了。
错误信息如下:
../../../build/../util/TimerContainer.cc:89: 错误:expected `;' before  rit’
../../../build/../util/TimerContainer.cc:90: 错误:rit 在此作用域中尚未声明
../../../build/../util/TimerContainer.cc: In member function ‘bool Vocal::TimeAndDate::TimerContainer<Msg>::cancel(void*)’:
../../../build/../util/TimerContainer.cc:111: 错误:expected `;' before it’
../../../build/../util/TimerContainer.cc:113: 错误:it 在此作用域中尚未声明
../../../build/../util/TimerContainer.cc: In member function ‘std:stream& Vocal::TimeAndDate::TimerContainer<Msg>::writeTo(std:stream&) const’:
../../../build/../util/TimerContainer.cc:185: 错误:expected `;' before it’
../../../build/../util/TimerContainer.cc:187: 错误:it 在此作用域中尚未声明

下面是两个源文件:
========================TimerContainer.hxx=================
static const char* const TimerContainerHeaderVersion =
"$Id: TimerContainer.hxx,v 1.14 2001/01/24 22:23:41 bko Exp $";


#include "TimerEntry.hxx"
#include "Writer.hxx"
#include "Sptr.hxx"
#include <list>
#include "VMissingDataException.hxx"



/** Infrastructure common to VOCAL.
*/
namespace Vocal
{


/** Infrastructure common to VOCAL to manipulate the time.<br><br>
*/
namespace TimeAndDate
{


/** An ordered list of TimerEntries. This list is a list of events and the
* time those events expire.<br><br>
*
* @see Vocal::TimeAndDate::TimerEntry
*/
template < class Msg >
class TimerContainer : public Vocal::IO::Writer
{
public:


/** Default constructor
*/
TimerContainer();


/** Virtual destructor
*/
virtual ~TimerContainer();


/** Add a new message to the timer.
*/
TimerEntryId add(Sptr < Msg > ,
milliseconds_t relativeTime);


/** Cancel a delayed event. Returns true is id was found, and
* false otherwise.
*/
bool cancel(TimerEntryId);


/** Get the timeout value for the first available
* message. Returns -1 if no messages available
* (conveying infinite timeout).
*/
int getTimeout();


/** Returns the identifier of the first entry.
*/
TimerEntryId getFirstTimerEntryId();


/** Returns true if a message is available.
*/
bool messageAvailable();


/** Returns the first message available. Throws a
* status exception if no messages are available.
*/
Sptr < Msg > getMessage()
throw ( VMissingDataException );


/** Write a TimerContainer to an ostream.
*/
ostream & writeTo(ostream & out) const;


/** Return the number of all the pending events in the TimerContainer
*/
unsigned int size() const;


private:

list < TimerEntry < Msg > > timerList_;
};


} // namespace Time
} // namespace Vocal


#include "TimerContainer.cc"


#endif // !defined(TIMER_CONTAINER_DOT_H)



=======================TimerContainer.cc===================
static const char* const TimerContainer_cc_Version =
"$Id: TimerContainer.cc,v 1.12 2000/12/18 23:49:06 bko Exp $";


#include "VMissingDataException.hxx"


using namespace Vocal;
using TimeAndDate::TimerContainer;
using TimeAndDate::TimerEntry;
using TimeAndDate::milliseconds_t;
using TimeAndDate::TimerEntryId;


template < class Msg >
TimerContainer < Msg > ::TimerContainer()
{
}



template < class Msg >
TimerContainer < Msg > ::~TimerContainer()
{
}



template < class Msg >
TimerEntryId
TimerContainer < Msg > ::add(
Sptr < Msg > msg,
milliseconds_t relativeTime
)
{
TimerEntry < Msg > newTimerEntry(msg, relativeTime);

list < TimerEntry < Msg > > ::reverse_iterator rit;//提示rit未声明
for ( rit = timerList_.rbegin(); rit != timerList_.rend(); rit++ )
{
if ( newTimerEntry >= *rit )
{
timerList_.insert(rit.base(), newTimerEntry);
break;
}
}
if ( rit == timerList_.rend() )
{
timerList_.push_front(newTimerEntry);
}

return ( newTimerEntry.getId() );
}


template < class Msg >
bool
TimerContainer < Msg > ::cancel(TimerEntryId msg_id)
{
list < TimerEntry < Msg > > ::iterator it;//提示it未声明

for ( it = timerList_.begin(); it != timerList_.end(); it++ )
{
if ( (*it).getId() == msg_id )
{
timerList_.erase(it);
return ( true );
}
}
return ( false );
}


template < class Msg >
int
TimerContainer < Msg > ::getTimeout()
{
int timeout = timerList_.size() > 0
? timerList_.front().getTimeout()
: -1;

// Nothing in the list, so return infinite timeout (-1).
//
return ( timeout );
}


template < class Msg >
TimerEntryId
TimerContainer < Msg > ::getFirstTimerEntryId()
{
TimerEntryId id = timerList_.size() > 0
? timerList_.front().getId()
: 0;
return ( id );
}


template < class Msg >
bool
TimerContainer < Msg > ::messageAvailable()
{
bool msgAvailable = ( timerList_.size() > 0 && timerList_.front().hasExpired() );

return ( msgAvailable );
}


template < class Msg >
Sptr < Msg >
TimerContainer < Msg > ::getMessage()
throw ( VMissingDataException )
{
if ( !messageAvailable() )
{
throw VMissingDataException("TimerContainer::getMessage: no message available.",
__FILE__, __LINE__);
}

Sptr < Msg > msg = timerList_.front().getMessage();
timerList_.pop_front();

return ( msg );
}


template < class Msg >
ostream &
TimerContainer < Msg > ::writeTo(ostream & out) const
{
out << "timer container (size: " << timerList_.size() << ") = { ";
bool first = true;

list < TimerEntry < Msg > > ::const_iterator it;//提示it未声明

for ( it = timerList_.begin(); it != timerList_.end(); it++ )
{
if ( first )
{
out << " (";
first = false;
}
else
{
out << ", (";
}

out << *it << " )";
}

return ( out << " }" );
}


template < class Msg >
unsigned int
TimerContainer < Msg > ::size() const
{
return ( timerList_.size() );
}

[ 本帖最后由 miidii 于 2005-11-16 22:51 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2005-11-16 22:20 |只看该作者
将using namespace Vocal改为using namespace std.

不是改为,而是添加,两个名空间都要。
在实现文件.cc里面
using namespace Vocal;
using namespace std;

不行的话,再在.cc里面加上
#include <iterator>,通常list里面应当引入了迭代器。

论坛徽章:
0
3 [报告]
发表于 2005-11-16 22:47 |只看该作者
谢谢renston921的回复。我试过了,仍然提示一样的错误,请你再帮助看看,谢谢。

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
4 [报告]
发表于 2005-11-16 23:21 |只看该作者
你是怎么编译的?

论坛徽章:
0
5 [报告]
发表于 2005-11-17 09:33 |只看该作者
这是VOCA mgcp协义栈的程序,使用make编译,编译到这一步提示出错,无法继续下去。这里还有一个global.h在编译的时也会装入,这是在装入其他头文件时装入的,我也把它贴出来:
==========global.h===================
#ifndef GLOBAL_H_
#define GLOBAL_H_


#ifdef USE_DMALLOC
#include <dmalloc.h>
#endif

#ifdef __sgi
#include <pthread.h>
#include <string>
#endif

#ifdef __cplusplus
using namespace std;
#endif

/* this is used to turn of unused warnings in GCC */

#ifdef __GNUC__
#define UNUSED_VARIABLE __attribute__((__unused__))
#else
#define UNUSED_VARIABLE
#endif

#endif


我的编译环境是:
libpq++-4.0-305
compat-libstdc++-5.0.7-6
libstdc++-4.0.2_20050901-3
CommonC++-devel-2.1.3.1-2
libsigc++12-1.2.7-3
ImageMagick-Magick++-devel-6.2.3-4
libstdc++-devel-4.0.2_20050901-3
gcc-c++-4.0.2_20050901-3
CommonC++-doc-2.1.3.1-2
libsigc++2-2.0.16-3
ImageMagick-Magick++-6.2.3-4
libsigc++12-devel-1.2.7-3
libsigc++2-devel-2.0.16-3
CommonC++-2.1.3.1-2

请高手帮忙看看,gh十分感谢!!

论坛徽章:
0
6 [报告]
发表于 2005-11-17 12:24 |只看该作者
有高手知道吗?


加入#include < iterator>
using namespace std;
甚至在list<...>::iterator rit 之前使用std:: 居然提示的是一样的错误,这到底是怎么回事,是程序的问题还是其他部分的问题?高手路过,请一定指点一下,工作进行不下去了,谢谢!!

论坛徽章:
0
7 [报告]
发表于 2005-11-17 13:01 |只看该作者
typename list < TimerEntry < Msg > > ::reverse_iterator rit;

看一下是不是上面的.
新标准里面好象要求在.某个类模板中使用另一个类模板中定义的类型时,需要加typename来说明这是一个类型的名字.你试一下是不是这个问题.

论坛徽章:
0
8 [报告]
发表于 2005-11-17 19:09 |只看该作者
非常感谢reinstone921,真是这个原因。这个问题搞了我两天了,真是谢谢。
这个问题解决了,又有其他程序出问题了,我先研究一下,不行的话还得向你请教。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP