#ifndef CLASS_VEHICLE_
#define CLASS_VEHICLE_
#include "ns3/ptr.h"
#include "ns3/object.h"
#include "ns3/vector.h"
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/mobility-module.h"
#include "ns3/config-store-module.h"
#include "ns3/wifi-module.h"
#include "Cluster.h"
namespace ns3
{
class Cluster;
/// define type DeviceTraceCallback
typedef Callback<void, Ptr<Vehicle>, std::string, Ptr<const Packet> > DeviceTraceCallback; // Line where the error is
/// define type VehicleReceiveCallback.
typedef Callback<void, Ptr<Vehicle>, Ptr<const Packet>, Address> VehicleReceiveCallback;
/// define type PhyRxOkTraceCallback.
typedef Callback<void, Ptr<Vehicle>, std::string, Ptr<const Packet>, double, WifiMode, enum WifiPreamble> PhyRxOkTraceCallback;
/// define type PhyRxErrorTraceCallback.
typedef Callback<void, Ptr<Vehicle>, std::string, Ptr<const Packet>, double> PhyRxErrorTraceCallback;
/// define type PhyTxTraceCallback.
typedef Callback<void, Ptr<Vehicle>, std::string, Ptr<const Packet>, WifiMode, WifiPreamble, uint8_t> PhyTxTraceCallback;
/// define type PhyStateTraceCallback.
typedef Callback<void, Ptr<Vehicle>, std::string, Time, Time, enum WifiPhy::State> PhyStateTraceCallback;
class Vehicle : public ns3::Object
{
... code section
};
};
#endif
I am working on ns3, and I’ve to implement a code which could let me do some simulations about vehicular networks. I have several classes, but only one is annoying. Indeed when I compile I have this particular error:
“/src/vanet/model/Vehicle.h:45: error: invalid declarator before ‘DeviceTraceCallback’”
and it brings a tons other errors as
“/src/vanet/model/Vehicle.h:212: error: ‘DeviceTraceCallback’ does not name a type”
or
“../src/vanet/model/Vehicle.h:214: error: ‘DeviceTraceCallback’ has not been declared”.
I really don’t understand what I did wrong, so if someone could help me it would be very nice!
You haven’t shown us which source line the error refers to, but I’ll assume it’s this one:
Have all the types and templates mentioned in that line been declared in one of the headers you’ve included? In particular:
<string>. It’s a good idea to do that, even if one of the other headers might include it indirectly.Vehicletype, defined later in this file. You’ll need a declaration (class Vehicle;insidenamespace ns {}) before you can use it in this declaration.