#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
我正在研究ns3,我将实现一个代码,可以让我对车载网络进行一些模拟。我有几节课,但只有一节很烦人。确实,当我编译时,我有这个特殊的错误:
“/ src / vanet / model / Vehicle.h:45:错误:'DeviceTraceCallback'之前的声明符无效”
它带来了其他的错误
“/ src / vanet / model / Vehicle.h:212:错误:'DeviceTraceCallback'没有命名类型”
或
“../ src / vanet / model / Vehicle.h:214:错误:'DeviceTraceCallback'尚未声明”。
我真的不明白我做错了什么,所以如果有人能帮助我,那就太好了!
答案 0 :(得分:3)
您没有向我们展示错误引用的源代码行,但我会假设它是这一行:
typedef Callback<void, Ptr<Vehicle>, std::string, Ptr<const Packet> > DeviceTraceCallback;
该行中提到的所有类型和模板是否已在您包含的其中一个标题中声明?特别是:
<string>
。这样做是个好主意,即使其他标题之一可能间接包含它。Vehicle
类型。在此声明中使用之前,您需要声明(class Vehicle;
内namespace ns {}
)。