Ptr class and class forward declarations

61 views
Skip to first unread message

Hugo Sousa Pinto

unread,
Mar 21, 2016, 9:22:27 PM3/21/16
to ns-3-users
Hello:

I am trying to add a queue in my own netdevice class, so I am just replicating what is in point-to-point-netdevice.h. In this file, there is a forward declaration of 

class Queue; 

and then a Ptr<Queue> m_queue; is declared as class member. 

However, if I do this in my class I get an error::

./ns3/ptr.h:756:7: error: invalid use of incomplete type ‘struct ns3::Queue’
../src/openflow/model/openflow-switch-net-device.h:75:7: error: forward declaration of ‘struct ns3::Queue’

If I use *Queue instead of Ptr<Queue> the code compiles fine. From the point-to-point code it looks like the Ptr works fine with class forward declaration, so any idea of why it does not work in my code?

Thank you


Craig Dowell

unread,
Mar 21, 2016, 10:38:09 PM3/21/16
to ns-3-...@googlegroups.com
Are you sure you are replicating what is in the point to point net device? Is there a Ptr<Queue> m_queue member variable in the point to point class?

Google incomplete type.
--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

Hugo Sousa Pinto

unread,
Mar 21, 2016, 11:03:36 PM3/21/16
to ns-3-...@googlegroups.com

Yes. The problem was that include queue.h was missing in the .cc file. The ptr class probably only dereferences the class after the .cc file is included which is why it works I assume

> You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/1wcbJA5upqk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.

Nat P

unread,
Mar 22, 2016, 8:50:19 AM3/22/16
to ns-3-users
Hi please look at the new code, we have a traffic control layer for that. Using queue in netdevice is something really not needed, now..

About your issue, it's simply: somewhere in the code you are inlining a function with a queue, or you are referencing it directly. In either cases, the compiler should know the size of the pointer, otherwise it will complain.

Nat
Reply all
Reply to author
Forward
0 new messages