- 论坛徽章:
- 0
|
编译一个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 编辑 ] |
|