If you turn on verbose compilation in Preferences and then examine the output in the black console window at the bottom of the Arduino IDE window after compilation, you will find the location of the temporary build folder. The sketch subfolder of the temporary build folder contains the .cpp file that was generated from your sketch after the preprocessor had its way with it:
#include <Arduino.h>
#line 1 "C:\\Users\\per\\Desktop\\arduino-odd-behavior-demo-01-master\\typedefstruct_fail\\typedefstruct_fail.ino"
#line 1 "C:\\Users\\per\\Desktop\\arduino-odd-behavior-demo-01-master\\typedefstruct_fail\\typedefstruct_fail.ino"
#line 2 "C:\\Users\\per\\Desktop\\arduino-odd-behavior-demo-01-master\\typedefstruct_fail\\typedefstruct_fail.ino"
void setup();
#line 5 "C:\\Users\\per\\Desktop\\arduino-odd-behavior-demo-01-master\\typedefstruct_fail\\typedefstruct_fail.ino"
void loop();
#line 17 "C:\\Users\\per\\Desktop\\arduino-odd-behavior-demo-01-master\\typedefstruct_fail\\typedefstruct_fail.ino"
bool testfunc(SensorData &_data);
#line 2 "C:\\Users\\per\\Desktop\\arduino-odd-behavior-demo-01-master\\typedefstruct_fail\\typedefstruct_fail.ino"
void setup() {
}
void loop() {
}
typedef struct {
const char* name;
int time;
float value;
} SensorData;
/* no error on the next line, why? */
SensorData sdata;
bool testfunc(SensorData &_data) {
}
You can see the cause of the error and also that the #line directive causes the error message to reference line 17.
As you suspected, this is not a problem with the compiler, it's the sketch preprocessor. They did a big rewrite of it when they moved preprocessing to a tool separate from the IDE named arduino-builder that was released with Arduino IDE 1.6.6 and then slowly improved over time to where it's now better than the old system but still fails in some cases. The word is they are now going to rework it again (Redirecting to Google Groups) but from what I can see it's been slow going:
GitHub - arduino/arduino-preprocessor: Parses an Arduino Sketch and converts it into valid C++ source code
So I don't know what this means for arduino-builder. I'm not sure if it's worth reporting issues such as this since it's possible they are already fixed in arduino-preprocessor. I also think it's likely that the preprocessor will never be smart enough to always get prototype generation right and there's a certain point where you have to say "good enough". Where that point is, only the Arduino developers or management can say. If you like, you could submit an error report to the arduino-builder repository but please spend some time searching through the issues and pull requests first to make sure it hasn't already been reported:
Issues · arduino/arduino-builder · GitHub