Alex Rivera | Logout

Error: incomplete type used in nested name specifier

Asked 2010-12-31T21:57:52.673
20

There are 2 non-template classes A, B having some static template methods.

From class A static method in B is called and from class B static method from A is called. The source code only for illustration (not real code)...

A.h

#include "B.h"
class A 
{
 public:
   template <class T>
   void f1 ()
   {
      T var1= ...;
      T var2 = B::f4(T);
   }

   template <class T>
   T f2()
   {
      return ...
   }
};

#include "A.h"
class B
{
 public:
   template <class T>
   void f3 ()
   {
      T var1= ...;
      T var2 = A::f2(T); //Error
   }

   template <class T>
   T f4()
   {
      return ...
   }
};

I am having troubles with g++ compiler in NetBeans. During the compilation the following error occurs: Error: incomplete type A used in nested name specifier, g++.

I tried to add forward declarations into both classes, but nothing was successful.

There is an older bug:

http://gcc.gnu.org/ml/gcc-bugs/2005-02/msg01383.html

Edit
Report

1 Answer

0

Your problem is circular header dependency.

answered 2010-12-31T22:05:16.427

Your Answer