C++: variable 'ns3::Ipv4RoutingTableEntry route' has initializer but incomplete type

StackOverflow https://stackoverflow.com/questions/9246846

  •  28-04-2021
  •  | 
  •  

Domanda

I am having trouble deciphering these error messages from 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’

Here is my ls-routing-protocol.h file:

#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;
    ...

And here the relevant snippet from the ls-routing-protocol.cc file:

#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
      ...
    }
    ...
}

As some of you may tell, I am working with ns-3. I have looked up my error in many places, and most of the advice has been to properly declare a few structs. However, we are not directly using structs in this code (or at least not that I know of). I am starting to think that it's an issue with our use of smart pointers, but I'm not really sure.

Also, in case it is of any help: documentation for ipv4_static_routing.h

È stato utile?

Soluzione

You need to #include <ipv4-routing-table-entry.h>. This is the first thing that you see when you look at the documentation of ns3::Ipv4RoutingTableEntry class.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top