tgsuperspec:
All these _ etc are conventions you can use or not use they have no true meaning in the language specifications
Many commanys have there own ideas, MicroSoft 10 years or so ago used so called Hungarian notation . where variable names tried to describe themselves for program documentation..
Naming conventions are a modern idiom, but names are better than callingvariable a,b.c etc only..
I'm so glad they dropped Hungarian notation with .NET... However, I know some ex-Microsoft developers who even now STILL use Hungarian notation, and it bugs the hell out of me! Horrible idea...
I do remember when all I had at my disposal was variables A-Z and A$-Z$ and floating point was non-existant... Those were the days...
But we digress...
In C and C++ things always have to be declared before they can be used. That "before" means lexically in the file - i.e., higher up the page.
You can "forward" declare something in C and C++ by putting in what is called a "prototype" - i.e., something that says "I am going to further define this later on, but this is roughly what it will look like". For a function that might be:
void function b(); // This is the prototype
void function a() {
b();
}
void function b() {
// ...
}
Function B is defined after function A, yet function A wants to call function B, so it need to know about it, so a prototype is added before function A to tell it that function B will be defined later.
You don't need to do any of that on the Arduino because the IDE does it all for you - it scans through your sketch looking for functions and builds up a list of prototypes which it then inserts into the top of your sketch after any #includes.
Now, if one of those functions has your own typedef or struct in it, where that typedef or struct is defined at the top of your sketch, the prototype (using that typedef or struct) will be inserted before the typedef or struct is defined, and the IDE isn't clever enough to know any better. So, it throws a wobbly because it doesn't know what the variable types in the prototypes are.
By moving the typedefs or structs into a header file and #include-ing them into your sketch at the top you are forcing those definitions to occur before where the prototypes are inserted.