I wanted to move some of my code out into a second tab in the Arduino IDE, to keep things better organised. At first, I only tried moving a function, and it seemed to work fine. I could call the function from the setup()
function in my main tab, and there were no problems compiling or uploading.
However, I tried putting a whole class into the second tab, and suddenly it didn't work any more. For example:
Tab 1:
TestClass obj;
void setup()
{
obj.init();
}
void loop()
{
//...
}
Tab 2:
class TestClass
{
public:
void init()
{
//...
}
};
When I tried to compile this, it gave me the following errors:
tab1:1: error: 'TestClass' does not name a type
tab1.ino: In function 'void setup()':
tab1:5: error: 'obj' was not declared in this scope
Why does it recognise a function in another tab, but not a class? Is there a way to make it work in the Arduino IDE, or do I need to use an alternative like Eclipse?
#include
?tab1
andtab2
respectively. The names were set using the IDE, so the underlying files are both.ino
.