I stumbled into an interesting gap in my understanding of enums in c++ just now. I have a sketch which includes the following:
} lightContext = Normal;
void startSpecials( LightContext newContext )
// ...do something
This is not allowed. I found the article on the site that talked about the typical hack for working with enums as function parameters and return types in sketches (put them in a separate header file), but couldn't get the approach to work. As a workaround, I changed startSpecials() to accept an int (which is the underlying type for the enum LightContext) and cast it to a LightContext inside the function. That works, but is kludgy.
I'd like to understand what's causing this problem, and why putting the enum and their related functions in a separate header file is the recommended solution.
FWIW, I'm coming at this from a C# perspective. In that language you can use enums as parameters or return types without doing anything funky. The situation is obviously different in c++, but it's unclear to me why it is.