src files from Xcode give me error: does not name a type in CodeBlocks

1k Views Asked by At

someone passed me an openFrameworks project src folder. The project has a class called "rectangle."

Inside the src folder there are main.h, testApp.cpp, testApp.h, rectangle.cpp, rectangle.h. I directly replace the src folder in my empty project, but the project won't compile.

I believe the search directories are right since the class files are also in the src folder.

However CB shows me the "error: Rectangle does not name a type" in testApp.h

 Rectangle myRect;

I already included the header files in testApp.h (#include "rectangle.h") and have the rectangle.h include ofMain.h

Not sure if I am doing the right way to include a class.

Thanks!

The testApp.h file:

enter image description here

The rectangle.h file:

enter image description here

The rectangle cpp:

enter image description here

file structure:

enter image description here

1

There are 1 best solutions below

2
Dietmar Kühl On

You don't give enough information so it is all speculation. However, my guess is that the barely visible ofBa... is the culprit! If this class happens to have a function called Rectangle, this names is found and it clearly isn't a type. Here is the short example you should have posted, demonstrating the problem:

class Rectangle
{
};

struct foo
{
    void Rectangle() {}
};

struct bar
    : foo
{
    Rectangle r;
};

One fix for the problem is to use ::Rectangle instead of Rectangle as this qualification forces the look-up at global scope.