问题描述
#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:error:'DeviceTraceCallback'没有命名类型或
../src/vanet/model/Vehicle.h:214:error:'DeviceTraceCallback'没有被声明。
我真的不明白我做错了什么,所以如果有人可以帮助我,这将是非常好的。
Hi 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 class, 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 !
Thx提前。
HL
推荐答案
您尚未向我们显示错误所指的来源,但我假设它是这个:
You haven't shown us which source line the error refers to, but I'll assume it's this one:
typedef Callback<void, Ptr<Vehicle>, std::string, Ptr<const Packet> > DeviceTraceCallback;
在该行中提到的所有类型和模板都已在您包含的标题之一中声明?特别是:
Have all the types and templates mentioned in that line been declared in one of the headers you've included? In particular:
- 您没有直接包含< string> 。
- 您尚未声明车辆类型,稍后在此文件中定义。您需要在此声明中使用声明( class Vehicle; 在 namespace ns {} 。
- You haven't directly included <string>. It's a good idea to do that, even if one of the other headers might include it indirectly.
- You haven't declared the Vehicle type, defined later in this file. You'll need a declaration (class Vehicle; inside namespace ns {}) before you can use it in this declaration.
这篇关于错误:无效的声明符之前与typedef的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!