LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 670|回复: 6

请高手指点,程序错在那里,该怎么改,十分感谢!

[复制链接]
发表于 2005-11-16 16:33:33 | 显示全部楼层 |阅读模式
编译一个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() );
}
发表于 2005-11-16 16:54:18 | 显示全部楼层
using namespace std; 加上试试?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-11-16 19:34:37 | 显示全部楼层
谢谢回复。
试过了,还是提示一样的错误。请帮忙再看看。
回复 支持 反对

使用道具 举报

发表于 2005-11-17 11:29:13 | 显示全部楼层
发帖不是这么发的,你的代码,要么用附件,要么用[code][/code]括起来,你现在这样,谁有空帮你整理阿
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-11-17 12:40:18 | 显示全部楼层
谢谢X11,初次发贴没有经验。我把原代码用附件发上去。你能帮我看看吗,工作进行不下去了。

我试过了加入#include <iterator>
     using namespace std;
甚至在list<...>之前用std::,居然提示的错误和没加一样,到底是程序本身的问题,还是其他问题。这里还有一个global.h会随其他头文件一起装入,不知会不会对程序有影响,一起发上去。
请一定帮忙。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

发表于 2005-11-17 13:15:59 | 显示全部楼层
最好把make的输出也存下来。g++编译时包含了哪些头文件也很重要,说不定就是少了什么(非标准库)头文件。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-11-17 19:23:00 | 显示全部楼层
谢谢楼上各位热情相助,在其他论坛问题获得解决。
需要在list前加上typename。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表