Reputation: 2318
I am trying to resolve a circular dependency in my c++ project and based on other answers here on StackOverflow, I followed the same methodology. However, I am still seeing an issue:
This is my code snippet below:
// In ip6.hh
namespace net
{
class Inet4;
/** IP6 layer */
class IP6
{
using Stack = class Inet4;
void set_packet_forwarding(Stack::Forward_delg fwd)
{ forward_packet_ = fwd; }
Stack& stack_;
}
}
// In Inet4.hpp
#include "ip6/ip6.hpp"
namespace net {
class Inet4 : public Inet<IP4>{
IP6& ip_obj()
{ return ip6_; }
IP6 ip6_;
}
}
In main.cpp, I am including it as follows:
#include <net/ip6/ip6.hpp>
#include <net/inet4.hpp>
> /home/nikhil/projects/ipv6/IncludeOS/api/net/ip6/ip6.hpp:84:32: error: > incomplete type 'net::Inet4' named in nested name specifier > void set_packet_forwarding(Stack::Forward_delg fwd) > ^~~~~~~ /home/nikhil/projects/ipv6/IncludeOS/api/net/ip6/ip6.hpp:35:9: note: > forward declaration of 'net::Inet4' class Inet4;
Upvotes: 0
Views: 417
Reputation: 1701
there is only Inet decalaration (not definition). Compiler does not know definition of Inet4 (hence Stack which is alaised to Inet4).
Upvotes: 2