I have a struct definition and several instances of it. The problem I'm encountering is that whitespace is behaving very weirdly. Even though whitespace should be ignored, it seems that, when I break up the instantiation onto multiple lines, I get errors when compiling.
To illustrate, if I write the following:
struct PatternConfig
{
uint8_t startingHue;
uint8_t endingHue;
bool cycleHues;
void (*pattern)();
};
PatternConfig p = { 0, 255, true, rainbow }
void rainbow()
{
// some colorful stuff
}
everything compiles and is happy. However, if I change it to add a little whitespace
// struct is the same
PatternConfig p = {
0,
255,
true,
rainbow
};
// rainbow function is the same
then I get an error about rainbow being undefined in scope
xmas_light:52:17: error: 'rainbow' was not declared in this scope
0, 255, true, rainbow};
I've seen this error before when I had some syntax error (e.g. a missing paren), but the only change between the two files is introducing the whitespace. My understanding is that the whitespace shouldn't matter in this context, but obviously there's something funky going on here. Also, the above is a somewhat contrived example; the structs I'm actually using are larger and, thus, cumbersome to read on one line, otherwise I'd just forget it and go for the one-liner.
Any ideas? Thanks in advance!