Tearing my hair out about something that is probably trivial


#1

I am drawing a blank on some error messages in an OSX XCode based test project, that is throwing out lots of “havent even got to first base yet” errors…

Ive enclosed a zip of the project, I’m not expecting every error gone, its just the initial ones - like “ChoiceElement.cpp:35:1: Incomplete type ‘rbf::ChoiceElement’ named in nested name specifier”

The basic problem has arisen once I decoded to switch from a “many classes in one hop/cpp file” to seperate hop and cpp files for EACH class.

Something to do with dependencies for sure, but i’m just stuck, on something that im sure for any expert - is actually a trivial thing.

Any help would be appreciated.

The zip file is the complete project but I havent included the stuff that would be inside the “jucelibrarycode/modules” folder since it would exceed the size limit - but its standard stuff of course.

I’m “Stuck”…


#2

I don’t have time to look, but that error means a class is referencing another class that has not yet been defined. Typically this hints to some circular dependancies going on. If you’re doing something like:


#include "B.h"

class A
{
  B b;
}



#include "A.h"

class B
{
  A a;
}

One of the classes will fail because the other will still be undefined. Often circular dependancies can be hard to spot as there may be chain of three or more classes before the loop occurs. You can get around it by just placing a pre-declare such as ‘class MyClass;’ in the header where the error occurs. Ideally though you should revisit your code and eliminate the tight coupling of classes.


#3

Thanks for getting back. Yes there are going to be plenty of circular dependencies.

What the project currently does is put forward declarations for every class into the single file: AttributeTest.hpp.

The first ( of many ) errors that is coming up, is for this CPP file :

ChoiceElement.cpp :

#ifndef CHOICEELEMENT_HEADER
#define CHOICEELEMENT_HEADER

#include “AttributeTest.hpp”
#include “AttributeTest_glob_extern.hpp”

// — Includes for class dependencies —

BEGIN_RBF_NAMESPACE

//**************************************** ChoiceElement *****************************************
//---------------------------------- ChoiceElement:: ChoiceElement ----------------------------------
ChoiceElement::ChoiceElement() : Index(0) {
}

END_RBF_NAMESPACE

#endif // CHOICEELEMENT_HEADER__


Now the corresponding HPP file contains this:

#ifndef CHOICEELEMENT_HEADER
#define CHOICEELEMENT_HEADER

#include “AttributeTest.hpp”
#include “AttributeTest_glob_extern.hpp”

BEGIN_RBF_NAMESPACE

//**************************************** ChoiceElement *****************************************
class ChoiceElement : public OBJECT
{
public:
STRING Item;
STRING ID;
int Index;

      ChoiceElement() ;

 protected:
 private:
      JUCE_LEAK_DETECTOR (ChoiceElement);

};

END_RBF_NAMESPACE

#endif // CHOICEELEMENT_HEADER__