0071 Classes Issue

I recently converted a project I had been working on in 007 to 0071. Everything worked fine except for a class I had made. I had the class in it’s own files (Block.h and block.cpp), but when I attempted to compile, it returned many errors in core iOS classes, mostly along the lines of “Unknown type name ‘Float64’” and some other file types.

Here’s a screen shot of the compiler: http://andymakes.com/extras/files/ofClassIssue.png

What I found was that when I declared my class in testApp instead of in its own file, I did not get these errors. And that making a new class in it’s own file was fine until I added the line #include “ofMain.h”

It’s working now, but obviously limiting myself to writing all of my code in testApp is going to get cumbersome very quickly. Does anybody have any idea what’s going on when I try to include “ofMain.h” ?

Thanks.

![](http://forum.openframeworks.cc/uploads/default/2407/Screen Shot 2012-06-04 at 3.30.58 PM.png)

your pictures shows an error message “Workspace error integrity” which appears when you are using 2 projects referencing statically 2 same externals projects, AFAIK.

it means probably 2 OF projects are opened at the same time and the one you try to compile is the second opened.

here I noticed that.

That is true, and I should have taken another screen shot. I closed the other project and restarted xCode, but it did not change the issue.

could you please report this at https://github.com/openframeworks/openFrameworks/issues ?

Sure. I just did.

Weirdly enough, I’m having some success when I just keep all of my functions for a class inside the h file and don’t include ofMain.h

I created a test file with this class in a file named Ball.h

  
  
#ifndef emptyExample_Ball_h  
#define emptyExample_Ball_h  
  
class Ball{  
public:  
    int size;  
    ofPoint pos;  
      
    void setup(int _size, float x, float y){  
        size=_size;  
        pos.set(x,y);  
    }  
      
    void draw(){  
        ofSetColor(255,0,0);  
        ofCircle(pos.x, pos.y, size);  
    }  
};  
#endif  
  

This compiles and runs just fine. In testApp.h I am including “Ball.h” and my testApp.mm looks like this:

  
  
//--------------------------------------------------------------  
void testApp::setup(){	  
    ofBackground(127,127,127);  
      
    myBall.setup(30, 50, 50);  
}  
//--------------------------------------------------------------  
void testApp::update(){  
}  
//--------------------------------------------------------------  
void testApp::draw(){  
	myBall.draw();  
}  
  

(The other standard OF functions are there, but this is the only part that I changed at all)

I would have thought that not including “ofMain.h” in my Ball class would have caused issues, but it doesn’t seem to.

This method did not work at all when I tried making Ball.cpp. I immediately started getting the errors I was expecting to get when I put everything in the H file. Not including “ofMain.h” caused unknown type errors and unknown identifier errors.

Here is the code I used there

Ball.h:

  
#ifndef emptyExample_Ball_h  
#define emptyExample_Ball_h  
  
class Ball{  
public:  
    void setup(int _size, float x, float y);  
    void draw();  
      
    int size;  
    ofPoint pos;      
};  
#endif  
  

Ball.cpp:

  
#include "Ball.h"  
void Ball::setup(int _size, float x, float y){  
    size=_size;  
    pos.set(x,y);  
}  
void Ball::draw(){  
    ofSetColor(255,0,0);  
    ofCircle(pos.x, pos.y, size);  
}  
  

Attached are two screen shots of the errors I’m getting:

![](http://forum.openframeworks.cc/uploads/default/2411/Screen Shot 2012-06-06 at 4.19.57 PM.png)

![](http://forum.openframeworks.cc/uploads/default/2413/Screen Shot 2012-06-06 at 4.20.21 PM.png)

I solved the problem.

The issue seems to be with the fact that my class (the original one that prompted me to post) was called Block. After my post with the Ball test class, I tried just using int the include “ofMain.h” line with that class and it went off without a hitch. The only class that was giving my trouble was Block. I changed the name to ColorBlock and everything seems hunky dory.

I closed the issue report as well.

Thanks for the help.