c++ - ISO C++禁止声明多集

This question already has an answer here:
ISO C++ forbids declaration of ‘multiset’ with no type

(1个答案)


5年前关闭。




我正在尝试使用waf构建软件,但出现错误:
In file included from ../src/internet-stack/mp-tcp-typedefs.cc:6:
../src/internet-stack/mp-tcp-typedefs.h:151: error: ISO C++ forbids declaration of ‘multiset’ with no type
../src/internet-stack/mp-tcp-typedefs.h:151: error: expected ‘;’ before ‘<’ token
../src/internet-stack/mp-tcp-typedefs.cc: In member function ‘void ns3::MpTcpSubFlow::updateRTT(uint32_t, ns3::Time)’:
../src/internet-stack/mp-tcp-typedefs.cc:550: error: ‘measuredRTT’ was not declared in this scope
In file included from ../src/internet-stack/mp-tcp-socket-impl.cc:17:
../src/internet-stack/mp-tcp-typedefs.h:151: error: ISO C++ forbids declaration of ‘multiset’ with no type
../src/internet-stack/mp-tcp-typedefs.h:151: error: expected ‘;’ before ‘<’ token
In file included from ../src/internet-stack/mp-tcp-socket-impl.h:19,
                 from ../src/internet-stack/mp-tcp-l4-protocol.h:19,
                 from ../src/internet-stack/mp-tcp-l4-protocol.cc:11:
../src/internet-stack/mp-tcp-typedefs.h:151: error: ISO C++ forbids declaration of ‘multiset’ with no type
../src/internet-stack/mp-tcp-typedefs.h:151: error: expected ‘;’ before ‘<’ token
In file included from debug/ns3/mp-tcp-socket-impl.h:19,
                 from ../src/applications/packet-sink/mp-tcp-packet-sink.h:9,
                 from ../src/applications/packet-sink/mp-tcp-packet-sink.cc:13:
debug/ns3/mp-tcp-typedefs.h:151: error: ISO C++ forbids declaration of ‘multiset’ with no type
debug/ns3/mp-tcp-typedefs.h:151: error: expected ‘;’ before ‘<’ token
../src/internet-stack/mp-tcp-socket-impl.cc: In member function ‘void ns3::MpTcpSocketImpl::GenerateRTTPlot()’:
../src/internet-stack/mp-tcp-socket-impl.cc:1884: error: ‘class ns3::MpTcpSubFlow’ has no member named ‘measuredRTT’
../src/internet-stack/mp-tcp-socket-impl.cc:1901: error: ‘class ns3::MpTcpSubFlow’ has no member named ‘measuredRTT’
../src/internet-stack/mp-tcp-socket-impl.cc:1913: error: ‘multiset’ was not declared in this scope
../src/internet-stack/mp-tcp-socket-impl.cc:1913: error: expected primary-expression before ‘double’
../src/internet-stack/mp-tcp-socket-impl.cc:1913: error: expected ‘;’ before ‘double’
../src/internet-stack/mp-tcp-socket-impl.cc:1915: error: ‘it’ was not declared in this scope
../src/internet-stack/mp-tcp-socket-impl.cc:1917: error: ‘class ns

3::MpTcpSubFlow’ has no member named ‘measuredRTT’

我找不到解决该错误的方法:如您所见,我正确填充了 namespace 和 header 。

错误:ISO C++禁止声明“multiset”(无类型)。

代码是:
#include <vector>
#include <map>
#include "sequence-number.h"
#include "rtt-estimator.h"
#include "tcp-typedefs.h"
#include "ns3/ipv4-address.h"
#include "ns3/event-id.h"
#include <stdint.h>
#include <queue>
#include <list>
#include <set>

#include "ns3/object.h"
#include "ns3/uinteger.h"
#include "ns3/traced-value.h"
#include "ns3/trace-source-accessor.h"

#ifndef MP_TCP_TYPEDEFS_H
#define MP_TCP_TYPEDEFS_H

using namespace std;

namespace ns3 {

typedef enum {
  MP_NONE,        // 0
  MP_MPC,         // 1
  MP_ADDR,        // 2
  MP_JOIN} MpStates_t;
// Multipath actions

// congestion control algorithm
typedef enum {
  Uncoupled_TCPs,       // 0
  Linked_Increases,     // 1
  RTT_Compensator,      // 2
  Fully_Coupled         // 3
  } CongestionCtrl_t;

// connection phase
typedef enum {
  Slow_Start,                   // 0
  Congestion_Avoidance,         // 1
  DSACK_SS,                     // 2 DSACK Slow Start: a temporary slow start triggered after detecting spurious retransmission based on DSACK information
  RTO_Recovery                  // 3 Reconvery algorithm after RTO expiration
  } Phase_t;

typedef enum {
  Round_Robin        // 0
  //Collision_Avoidance         // 1
  } DataDistribAlgo_t;

typedef enum {
  NoPR_Algo,    // 0
  Eifel,        // 1
  TCP_DOOR,     // 2 Detection of Out-of-Order and Response
  D_SACK,       // 3 Duplicate SACK (Selective ACKnowledgement)
  F_RTO         // 4 Forward RTO-Recovery: Algorithm for detecting spurious retransmission timeouts
  } PacketReorder_t;

typedef enum {
  Step_1,       // 0
  Step_2,       // 1
  Step_3,       // 2
  Step_4        // 3 In this step of F-RTO do a standard Fast Recovery algorithm
  } FRtoStep_t;

class DSNMapping
{
public:
    DSNMapping ();
    DSNMapping (uint8_t sFlowIdx, uint64_t dSeqNum, uint16_t dLvlLen, uint32_t sflowSeqNum, uint32_t ack, Ptr<Packet> pkt);
    //DSNMapping (const DSNMapping &res);
    virtual ~DSNMapping();
    uint64_t dataSeqNumber;
    uint16_t dataLevelLength;
    uint32_t subflowSeqNumber;
    uint32_t acknowledgement;
    uint32_t dupAckCount;
    uint8_t  subflowIndex;
    uint8_t *packet;

    bool operator <  (const DSNMapping& rhs) const;

    // variables for reordering simulation
    // Eifel Algorithm
    bool     retransmited;
    uint64_t tsval; // TimesTamp value

/*
private:/
    bool original;
    */
};

typedef enum {
  NO_ACTION,       // 0
  ADDR_TX,
  INIT_SUBFLOWS} MpActions_t;

class MpTcpStateMachine : public TcpStateMachine
{
public:

    MpTcpStateMachine();
    virtual ~MpTcpStateMachine();

    string printState(States_t s);
    string printEvent(Events_t e);
    string printAction(Actions_t a);

};

class MpTcpSubFlow : public Object
{
public:
    static TypeId GetTypeId (void);

    MpTcpSubFlow ();
    ~MpTcpSubFlow ();
    MpTcpSubFlow (uint32_t TxSeqNb);

    void StartTracing (string traced);
    void CwndTracer (double oldval, double newval);

    void AddDSNMapping(uint8_t sFlowIdx, uint64_t dSeqNum, uint16_t dLvlLen, uint32_t sflowSeqNum, uint32_t ack, Ptr<Packet> pkt);
    void updateRTT (uint32_t ack, Time current);
    DSNMapping * GetunAckPkt (uint32_t awnd);

    uint16_t    routeId;
    bool        connected;
    States_t    state;
    Phase_t     phase;
    Ipv4Address sAddr;
    uint16_t    sPort;
    Ipv4Address dAddr;
    uint16_t    dPort;
    uint32_t    oif;

    EventId  retxEvent;
    uint32_t MSS;          // Maximum Segment Size
    //double   cwnd;
    TracedValue<double> cwnd;
    double   scwnd;         // smoothed congestion window
    uint32_t ssthresh;
    uint32_t maxSeqNb;     // it represent the highest sequence number of a sent byte. In general it's egual to ( TxSeqNumber - 1 ) until a retransmission happen
    uint32_t highestAck;   // hightest received ACK for the subflow level sequence number
    uint64_t bandwidth;

    list<DSNMapping*> mapDSN;
    multiset<double> measuredRTT;
    //list<double> measuredRTT;
    Ptr<RttMeanDeviation> rtt;
    Time     lastMeasuredRtt;
    uint32_t TxSeqNumber;
    uint32_t RxSeqNumber;

    // for losses simulation
    double   LostThreshold;
    bool     CanDrop;
    uint64_t PktCount;
    uint64_t MaxPktCount;
    uint32_t DropedPktCount;
    uint32_t MaxDropedPktCount;

    // Reordering simulation
    double   savedCWND;
    uint32_t savedSSThresh;
    bool     SpuriousRecovery;
    uint32_t recover;
    uint8_t  ackCount;      // count of received acknowledgement after an RTO expiration
    uint32_t ReTxSeqNumber; // higher sequence number of the retransmitted segment
    int      nbRecvAck;
};

class MpTcpAddressInfo
{
public:
    MpTcpAddressInfo();
    ~MpTcpAddressInfo();

    uint8_t     addrID;
    Ipv4Address ipv4Addr;
    Ipv4Mask    mask;
};

class DataBuffer
{
public:
    DataBuffer();
    DataBuffer(uint32_t size);
    ~DataBuffer();

    queue<uint8_t> buffer;
    uint32_t bufMaxSize;

    uint32_t Add(uint8_t* buf, uint32_t size);
    uint32_t Retrieve(uint8_t* buf, uint32_t size);
    Ptr<Packet> CreatePacket (uint32_t size);
    uint32_t ReadPacket (Ptr<Packet> pkt, uint32_t dataLen);
    bool     Empty();
    bool     Full ();
    uint32_t PendingData();
    uint32_t FreeSpaceSize();
};


}//namespace ns3
#endif //MP_TCP_TYPEDEFS_H

我上面的代码是mp-tcp-typedefs.h文件。

最佳答案

这意味着多集已通过类似于以下方式的方式进行了前向声明:

template < class T > class multiset;

这样的声明允许multised用作:
multiset<double> *pointer;

但不是:
multiset<double> measuredRTT;

以下代码与您的代码相同,但没有项目的标题,也没有取决于compiles without error的代码。
我只能得出结论,问题不在于您发布的代码,而在于其中的某些 header 中。
#include <vector>
#include <map>
#include <stdint.h>
#include <queue>
#include <list>
#include <set>

#ifndef MP_TCP_TYPEDEFS_H
#define MP_TCP_TYPEDEFS_H

using namespace std;

namespace ns3 {

typedef enum {
  MP_NONE,        // 0
  MP_MPC,         // 1
  MP_ADDR,        // 2
  MP_JOIN} MpStates_t;
// Multipath actions

// congestion control algorithm
typedef enum {
  Uncoupled_TCPs,       // 0
  Linked_Increases,     // 1
  RTT_Compensator,      // 2
  Fully_Coupled         // 3
  } CongestionCtrl_t;

// connection phase
typedef enum {
  Slow_Start,                   // 0
  Congestion_Avoidance,         // 1
  DSACK_SS,                     // 2 DSACK Slow Start: a temporary slow start triggered after detecting spurious retransmission based on DSACK information
  RTO_Recovery                  // 3 Reconvery algorithm after RTO expiration
  } Phase_t;

typedef enum {
  Round_Robin        // 0
  //Collision_Avoidance         // 1
  } DataDistribAlgo_t;

typedef enum {
  NoPR_Algo,    // 0
  Eifel,        // 1
  TCP_DOOR,     // 2 Detection of Out-of-Order and Response
  D_SACK,       // 3 Duplicate SACK (Selective ACKnowledgement)
  F_RTO         // 4 Forward RTO-Recovery: Algorithm for detecting spurious retransmission timeouts
  } PacketReorder_t;

typedef enum {
  Step_1,       // 0
  Step_2,       // 1
  Step_3,       // 2
  Step_4        // 3 In this step of F-RTO do a standard Fast Recovery algorithm
  } FRtoStep_t;

class DSNMapping
{
public:
    DSNMapping ();

    //DSNMapping (const DSNMapping &res);
    virtual ~DSNMapping();
    uint64_t dataSeqNumber;
    uint16_t dataLevelLength;
    uint32_t subflowSeqNumber;
    uint32_t acknowledgement;
    uint32_t dupAckCount;
    uint8_t  subflowIndex;
    uint8_t *packet;

    bool operator <  (const DSNMapping& rhs) const;

    // variables for reordering simulation
    // Eifel Algorithm
    bool     retransmited;
    uint64_t tsval; // TimesTamp value

/*
private:/
    bool original;
    */
};

typedef enum {
  NO_ACTION,       // 0
  ADDR_TX,
  INIT_SUBFLOWS} MpActions_t;

class MpTcpStateMachine 
{
public:

    MpTcpStateMachine();
    virtual ~MpTcpStateMachine();





};

class MpTcpSubFlow 
{
public:


    MpTcpSubFlow ();
    ~MpTcpSubFlow ();
    MpTcpSubFlow (uint32_t TxSeqNb);

    void StartTracing (string traced);
    void CwndTracer (double oldval, double newval);



    DSNMapping * GetunAckPkt (uint32_t awnd);

    uint16_t    routeId;
    bool        connected;

    Phase_t     phase;

    uint16_t    sPort;

    uint16_t    dPort;
    uint32_t    oif;


    uint32_t MSS;          // Maximum Segment Size
    //double   cwnd;

    double   scwnd;         // smoothed congestion window
    uint32_t ssthresh;
    uint32_t maxSeqNb;     // it represent the highest sequence number of a sent byte. In general it's egual to ( TxSeqNumber - 1 ) until a retransmission happen
    uint32_t highestAck;   // hightest received ACK for the subflow level sequence number
    uint64_t bandwidth;

    list<DSNMapping*> mapDSN;
    multiset<double> measuredRTT;
    //list<double> measuredRTT;


    uint32_t TxSeqNumber;
    uint32_t RxSeqNumber;

    // for losses simulation
    double   LostThreshold;
    bool     CanDrop;
    uint64_t PktCount;
    uint64_t MaxPktCount;
    uint32_t DropedPktCount;
    uint32_t MaxDropedPktCount;

    // Reordering simulation
    double   savedCWND;
    uint32_t savedSSThresh;
    bool     SpuriousRecovery;
    uint32_t recover;
    uint8_t  ackCount;      // count of received acknowledgement after an RTO expiration
    uint32_t ReTxSeqNumber; // higher sequence number of the retransmitted segment
    int      nbRecvAck;
};

class MpTcpAddressInfo
{
public:
    MpTcpAddressInfo();
    ~MpTcpAddressInfo();

    uint8_t     addrID;


};

class DataBuffer
{
public:
    DataBuffer();
    DataBuffer(uint32_t size);
    ~DataBuffer();

    queue<uint8_t> buffer;
    uint32_t bufMaxSize;

    uint32_t Add(uint8_t* buf, uint32_t size);
    uint32_t Retrieve(uint8_t* buf, uint32_t size);


    bool     Empty();
    bool     Full ();
    uint32_t PendingData();
    uint32_t FreeSpaceSize();
};


}//namespace ns3
#endif //MP_TCP_TYPEDEFS_H

/// Added just so that the linker does not complain about lack of missing main
int main(int argc, char* argv[] )
{
    return 0;
}

https://stackoverflow.com/questions/31887223/

上一篇:java - 为什么我无法定义数组?

下一篇:c++ - 错误 : too many template-parameter-lists

相关文章:

c++ - 如何检查库是否可以由特定的 g++ 版本编译?

c++ - 为什么 Visual Studio Community 2017 C++ 标准是 C++98?

linux - 如何重新配置​​ Kconfig 设置?

.net - Visual Studio "Any CPU"目标是什么意思?

Java:编辑并重新编译.jar?

c++ - getopt_long 不打印错误消息

c++ - 将 std::vector emplace_back() 与 std::pair 与构造函数初始化列表一起使用

android - 如何确定 AOSP 系统库二进制文件中使用了哪些源文件?

c - Windows Lua 到可执行文件

php - 在 Windows 上编译 php_excel (v1.0.0) 和 LibXL (v3.5.4.1)

相关文章:

c++ - 尝试编译我的wxWidgets程序时出现 “is_enum not declared i

java - 错误 : variable data might not have been init

c++ - 代码块错误

c# - 错误 'Cannot Convert double to int'

java - 为什么我无法定义数组?

java - Unresolved 编译问题: The method parseInt(String

sql-server - 从以下脚本获取错误

c++ - 奇怪的错误: undefined reference to `class::class(

c# - 并非所有代码路径都返回值: Unity

java - 变量名称不能在Eclipse中解析为变量错误(多重继承)