The C++ compiler in the Arduino IDE, which I assume is some fork of g++, is a worthy compiler and it supports a lot of modern C++ - lambdas and all sorts of things.
So it's really weird that it's been crippled to reject something that's been part of C from day one.
You cannot pass a pointer to a user defined struct or class to a function. It refuses to recognize the underlying type. Ditto references to structs or the structs themselves. Ditto any user defined types at all, even freaking enums.
This can only be deliberate, and I'm guessing it was done as a lazy hack to prevent inexperienced programmers from passing entire structs to functions, which could rapidly get painful on small processors like arduinos. But in the attempt to Save US All From Ourselves, they blocked all references and pointers to those types as well, and that's unacceptable.
This really makes a mess of some very simple, basic programming techniques, especially involving state machines, which is a lot of what arduinos are for.
I don't need workarounds. I know plenty of ways around this, and they're all poor style or inefficient. If the compiler author wants to turn passing structs into a warning or even disallow it, great. It's not that hard to add to that the compiler. But preventing things as fundamental as passing a ref or pointer to a struct makes simple coding harder and it doesn't actually help anyone.
This is most likely the cause of your problem, I have run into the situation a few times and inserting a function prototype at an appropriate location fixed it.
Oh for pity's sake. Is there a way to turn off the automatic generation of prototypes? I'm an experienced C++ programmer and I define (or declare) my functions before they are used, so I absolutely don't need the IDE adding incorrect crap to my already well formed code. If it's going to try to dumb down C++ so people don't have to create forward references, it should at least figure out when they are not needed. Barring that there need to be an Off switch.
If you provide a function prototype, the IDE will not attempt to generate a prototype for the function. Not sure if the automatic prototype generation can be entirely disabled.
You can also provide your own main() function, and do away with the necessity of having setup() and loop().
Actually, no. This IS deliberate behavior on the part of the IDE, and it's not making things better. It's teaching people bad C++ - in C++, you either define or declare everything before use. The IDE is trying to make that important aspect of the language go away in the name of "simplification" - and then hassling people who know the actual rules, by helpfully doing something wrong.
Imagine someone starting out coding with an Arduino and then trying to move C++ professionally, and getting confused about all this talk of forward references. That's a disservice.
I've been using C++ since the cfront days, so I'm not a typical arduino hobbyist. If there's a better IDE out there, I'd be willing to pay for it.
I haven't gone looking, but this thread begs the question - is there a 'graduate course' for our learners, that takes them from the handholding(childhood) of the IDE to a stand-alone 'grown up'(perhaps, someone should have used a slightly different, less negative, phrasing...) world?
Just asking, as it would seem some here believe there are two worlds - Arduino 'baby', and 'C++' adult, which would seem to suggest there's room for a 'training wheels' stage.