[Programming bug] cannot convert ‘ns3::QueueItem*’ to ‘ns3::Packet*’ in initialization.

55 views
Skip to first unread message

Frank Wang

unread,
Feb 23, 2017, 3:05:05 AM2/23/17
to ns-3-users
I was writing my module, and I have some code like this :
Ptr<Queue> my_queue;
Ptr<Packet> p_pkt;
my_queue
= CreateObject<DropTailQueue>()
p_pkt
= my_queue->Dequeue();

The module conform the organization this page asked.

In my top-wscript, I have this : module.cxxflags = ['-std=c++11', '-Wall', '-Wextra', '-fpermissive', '-w']

Could anyone help me with this?

Full bug report is here :
In file included from ./ns3/attribute.h:25:0,
                 
from ./ns3/attribute-accessor-helper.h:23,
                 
from ./ns3/core-module.h:12,
                 
from ../src/ns3dtn-bit/model/ns3dtn-bit.h:5,
                 
from ../src/ns3dtn-bit/model/ns3dtn-bit.cc:3:
./ns3/ptr.h: In instantiation of ns3::Ptr<T>::Ptr(const ns3::Ptr<U>&) [with U = ns3::QueueItem; T = ns3::Packet]’:
../src/ns3dtn-bit/model/ns3dtn-bit.cc:75:35:   required from here
./ns3/ptr.h:746:27: error: cannot convert ns3::QueueItem*’ to ns3::Packet*’ in initialization
   
: m_ptr (PeekPointer (o))
                           
^
./ns3/ptr.h: In instantiation of ns3::Ptr<T>::Ptr(const ns3::Ptr<U>&) [with U = ns3::Packet; T = ns3::QueueItem]’:
../src/ns3dtn-bit/model/ns3dtn-bit.cc:88:64:   required from here
./ns3/ptr.h:746:27: error: cannot convert ns3::Packet*’ to ns3::QueueItem*’ in initialization

Luciano Jerez Chaves

unread,
Feb 23, 2017, 6:38:25 PM2/23/17
to ns-3-users
Hi,

You can check the API doxygen in cases like that.
As you can see here https://www.nsnam.org/docs/release/3.26/doxygen/classns3_1_1_queue_item.html the QueueItem is an object that carries a packet inside it. You cannot cast it directly. You can use the member function to get the packet.

Cheers,

Frank Wang

unread,
Feb 24, 2017, 12:36:36 AM2/24/17
to ns-3-users
Thanks for your time, I thought I got the wrong API page here.
Your advice really helps!!
在 2017年2月24日星期五 UTC+8上午7:38:25,Luciano Jerez Chaves写道:
Reply all
Reply to author
Forward
0 new messages