错误:ISO C ++禁止声明没有类型的'core'

时间:2015-09-01 14:56:39

标签: c++

我在标题中收到错误。首先,我在stackoverflow和google中进行了搜索。有许多类似的错误,但我无法弄清楚如何解决错误。我在标题中的错误中遇到的一些错误如下。有很多错误,而不是下面的错误,但我只是把它们中的一些。

    core.cpp:9:102: error: ISO C++ forbids declaration of 'core' with no type [-fpermissive]
    uint32_t number_of_core_msg_types, uint32_t msg_q_size, uint32_t bytes_per_flit) throw(err) :

    core.cpp:9:102: error: 'int boost::core::core(const pe_id&, const uint64_t&, boost::shared_ptr<id_factory<long long unsigned int> >, boost::shared_ptr<tile_statistics>, logger&, boost::shared_ptr<random_gen>, boost::shared_ptr<memory>, uint32_t, uint32_t, uint32_t)' should have been declared inside 'boost::core'

    core.cpp: In function 'int boost::core::core(const pe_id&, const uint64_t&, boost::shared_ptr<id_factory<long long unsigned int> >, boost::shared_ptr<tile_statistics>, logger&, boost::shared_ptr<random_gen>, boost::shared_ptr<memory>, uint32_t, uint32_t, uint32_t)':

    core.cpp:10:5: error: only constructors take member initializers
 pe(id), system_time(t), stats(st), log(l), ran(r),

这是我的core.hpp文件:

    #ifndef __CORE_HPP__
    #define __CORE_HPP__

    #include <vector>
    #include <map>
    #include <boost/shared_ptr.hpp>
    #include <boost/bind.hpp>
    #include "id_factory.hpp"
    #include "logger.hpp"
    #include "statistics.hpp"
    #include "pe.hpp"
    #include "random.hpp"
    #include "bridge.hpp"
    #include "messages.hpp"
    #include "memory.hpp"

    using namespace std;
    using namespace boost;

   /* core class provides common constructor process and connect process */

    #define MAX_PAYLOAD 256

    class core : public pe {
    public:
           core(const pe_id &id, const uint64_t &system_time,
               shared_ptr<id_factory<packet_id> > packet_id_factory,
               shared_ptr<tile_statistics> stats, logger &log,
               shared_ptr<random_gen> ran,
               shared_ptr<memory> mem,
               uint32_t number_of_core_msg_types, 
               uint32_t msg_queue_size, uint32_t m_bytes_per_flit) throw(err);
     virtual ~core() throw();

     /* Common core methods */
     virtual void connect(shared_ptr<bridge> net_bridge) throw(err);
     virtual void tick_positive_edge() throw(err);
     virtual void tick_negative_edge() throw(err);

    /* Fast forwarding */
    virtual uint64_t next_pkt_time() throw(err);
    virtual bool is_drained() const throw() = 0;

    /* not used */
    virtual void add_packet(uint64_t time, const flow_id &flow, uint32_t len) throw(err);
    virtual bool work_queued() throw(err);
    virtual bool is_ready_to_offer() throw(err);
    virtual void set_stop_darsim() throw(err);

    protected:
    /* implement core logic */
    virtual void execute() = 0;
    /* check and update finished memory requests */
    virtual void update_from_memory_requests() = 0;

    void tick_positive_edge_memory() throw(err);
    void tick_negative_edge_memory() throw(err);

    /* use these queues to use the network */
    shared_ptr<messageQueue> receive_queue(uint32_t type);
    shared_ptr<messageQueue> send_queue(uint32_t type);

    /* Global time */
    const uint64_t &system_time;

    /* Aux */
    shared_ptr<tile_statistics> stats;
    logger &log;
    shared_ptr<random_gen> ran;

    uint32_t m_number_of_msg_types;
    uint32_t m_first_core_msg_type;
    uint32_t m_msg_queue_size;
    uint32_t m_bytes_per_flit;

    /* memory */
    shared_ptr<memory> m_memory;

    private:
    typedef struct {
         packet_id id;
         flow_id flow;
         uint32_t len;
         uint32_t xmit;
         uint64_t payload[MAX_PAYLOAD];
    } core_incoming_packet_t;
    typedef map<uint32_t, core_incoming_packet_t> incoming_packets_t;

    void release_xmit_buffer();

    map<uint32_t/*msg type*/, shared_ptr<messageQueue> > m_out_msg_queues;
    map<uint32_t/*msg type*/, shared_ptr<messageQueue> > m_in_msg_queues;

    /* Network */
    shared_ptr<bridge> m_net;
    vector<uint32_t> m_queue_ids;
    incoming_packets_t m_incoming_packets;
    shared_ptr<id_factory<packet_id> > m_packet_id_factory;
    map<uint32_t, uint64_t*> m_xmit_buffer;

    uint32_t m_receive_channel_round_robin_pointer;
    uint32_t m_send_queue_round_robin_pointer;

    };

    #endif

这里是core.cpp文件的相关部分:

#include "core.hpp"

core::core(const pe_id &id, const uint64_t &t, shared_ptr<id_factory<packet_id> > pif,
       shared_ptr<tile_statistics> st, logger &l, shared_ptr<random_gen> r,
       shared_ptr<memory> mem,
       uint32_t number_of_core_msg_types, uint32_t msg_q_size, uint32_t bytes_per_flit) throw(err) :
pe(id), system_time(t), stats(st), log(l), ran(r),
m_msg_queue_size(msg_q_size), m_bytes_per_flit(bytes_per_flit), m_memory(mem), m_packet_id_factory(pif),
m_receive_channel_round_robin_pointer(0), m_send_queue_round_robin_pointer(0)
{
       m_number_of_msg_types = number_of_core_msg_types + mem->number_of_mem_msg_types();
       m_first_core_msg_type = mem->number_of_mem_msg_types();
       for (uint32_t i = 0; i < m_number_of_msg_types; ++i) {
              m_in_msg_queues[i] = shared_ptr<messageQueue> (new messageQueue(i, m_msg_queue_size));
              m_out_msg_queues[i] = shared_ptr<messageQueue> (new messageQueue(i, m_msg_queue_size));
       }
       m_memory->set_core_send_queues(m_out_msg_queues);
       m_memory->set_core_receive_queues(m_in_msg_queues);
 }

core::~core() throw() { }

void core::connect(shared_ptr<bridge> net_bridge) throw(err) {
    m_net = net_bridge;
    shared_ptr<vector<uint32_t> > qs = m_net->get_ingress_queue_ids();
    m_queue_ids.clear();
    copy(qs->begin(), qs->end(), back_insert_iterator<vector<uint32_t> >(m_queue_ids));
}

shared_ptr<messageQueue> core::receive_queue(uint32_t type) {
    assert((uint32_t)type < m_number_of_msg_types);
    return m_in_msg_queues[type];
}

shared_ptr<messageQueue> core::send_queue(uint32_t type) {
    assert((uint32_t)type < m_number_of_msg_types);
    return m_out_msg_queues[type];
}

void core::release_xmit_buffer() {
/* release xmit buffer for injection if transmission is done */
    for (map<uint32_t, uint64_t*>::iterator i = m_xmit_buffer.begin(); i != m_xmit_buffer.end(); ++i) {
        if (m_net->get_transmission_done(i->first)) {
            delete[] i->second;
            m_xmit_buffer.erase(i->first);
            break;
        }
    }
}
.......
.......
.......

有谁可以指出问题是什么?顺便说一句,我正在尝试编译程序,这些代码是程序的一部分。

0 个答案:

没有答案