I'm a tutor for an undergrad class in robotics, and we use robotC (for NXT robotics, version 4.50) as the platform of choice. A strange quirk in robotC that I've noticed is that, for some reason, #pragma config preprocessor directives only work when they are the first lines of the program.
#pragma config(Sensor, S1, touch, SensorTouch)
//comment
#pragma config(Sensor, S2, touch2, SensorTouch)
task main()
{
while(true){
nxtDisplayTextLine(0,"%i",SensorValue(touch));
nxtDisplayTextLine(1,"%i",SensorValue(touch2));
}
}
When I run this simple program, I get the following compilation errors:
**Error**:'#pragma config(...)' must be first lines of source file
**Error**:Undefined variable 'touch2'. 'short' assumed.
What is the reason for that first error? I can't find anything on the documentation listing a reason why #pragma config() has to be the first lines of the source file, just that it has to be.
EDIT: To clarify. I understand that the error is caused by having the //comment on the second line of the program, as #pragma config() lines have to be the first line(s) of the program. I'm wondering why #pragma config lines HAVE to be the first lines.