Hi Tim,
Hi Tim,
Related to my previous post about mixed messages from intellisense, I have another problem which I really don’t understand.
I have a large, historical Arduino sketch built with .ino files. I am now trying to make this more modular and am trying to add a .cpp/.h file to the sketch. Is it possible to work with ino and cpp files in one sketch – I am certainly having problems!
A number of global structures are declared and defined in the master.ino file and I wish to access these structures from a function in my .cpp.
I have reduced the problem to the simplest sketch I can make. In my master.ino I have something like this:
#include "Addon.h"
Struct aaSStruct
{
int aa1;
int aa2;
} aaInstance;
void setup()
{
DoAddon();
/* add setup code here */
}
void loop()
{
/* add main program code here */
}
I have an Addon.cpp file containing the following
#include "Addon.h"
void DoAddon()
{
aaInstance.aa1 = 1;
}
And Addon.h containing the following:
void DoAddon(); //Forward declaration - OK
struct aaStruct; //Incomplete declaration - Works IN VS C++ project
extern aaStruct aaInstance; //Forward declaration aaInstance
I have played with this for a couple of hours and the only way I can make it compile is to have a partial declaration of aaStruct in Addon.h and then a full declaration at the beginning of Addon.cpp. But then intellisense isn't happy at all.
Can you give me some words of wisdom on how to get this tiny sketch compiled without the screen being full of red lines?
Do you have any guidelines on how to make ino files and cpp files play nicely together?
Thanks
N