0

我无法从 g++ 中破译这些错误消息

../upenn-cis553/ls-routing-protocol/ls-routing-protocol.cc:533:29: error: variable ‘ns3::Ipv4RoutingTableEntry route’ has initializer but incomplete type
../upenn-cis553/ls-routing-protocol/ls-routing-protocol.cc:533:64: error: invalid use of incomplete type ‘struct ns3::Ipv4RoutingTableEntry’

这是我的 ls-routing-protocol.h 文件:

#include "ns3/ipv4.h"
#include "ns3/ipv4-routing-protocol.h"
#include "ns3/ipv4-static-routing.h"
#include "ns3/object.h"
#include "ns3/packet.h"
#include "ns3/node.h"
#include "ns3/socket.h"
#include "ns3/timer.h"

#include "ns3/ping-request.h"
#include "ns3/penn-routing-protocol.h"
#include "ns3/ls-message.h"

#include <vector>
#include <map>

...

private:
    ...
    Ptr<Ipv4StaticRouting> m_staticRouting;
    ...

这里是来自 ls-routing-protocol.cc 文件的相关片段:

#include "ns3/ls-routing-protocol.h"
#include "ns3/socket-factory.h"
#include "ns3/udp-socket-factory.h"
#include "ns3/simulator.h"
#include "ns3/log.h"
#include "ns3/random-variable.h"
#include "ns3/inet-socket-address.h"
#include "ns3/ipv4-header.h"
#include "ns3/ipv4-route.h"
#include "ns3/uinteger.h"
#include "ns3/test-result.h"
#include <sys/time.h>

using namespace ns3;


void
LSRoutingProtocol::AuditRoutes ()
{
   int i;
   int n = m_staticRouting->GetNRoutes();
   for (i=0; i < n; i++)
    {
      Ipv4RoutingTableEntry route = m_staticRouting->GetRoute(i); // ERROR
      ...
    }
    ...
}

正如你们中的一些人所说,我正在使用 ns-3。我在很多地方查找了我的错误,大多数建议都是正确声明一些结构。但是,我们并没有在这段代码中直接使用结构(或者至少我不知道)。我开始认为这是我们使用智能指针的问题,但我不太确定。

此外,如果有任何帮助:ipv4_static_routing.h 的文档

4

1 回答 1

0

你需要#include <ipv4-routing-table-entry.h>。这是您查看class文档时首先看到的内容ns3::Ipv4RoutingTableEntry

于 2012-02-12T06:06:26.527 回答