ROBOTC.net forums
http://robotc.net/forums/

Strange bug with comments before #pragma compiler directive
http://robotc.net/forums/viewtopic.php?f=1&t=2096
Page 1 of 1

Author:  ggarcia [ Sun Jan 10, 2010 6:49 pm ]
Post subject:  Strange bug with comments before #pragma compiler directive

I noticed a strange bug when some pragma directives are preceded by a comment. I reduced the program to the very minimum and obtained this:

Code:
// Some comment
#pragma config(Sensor, S2,              startStop,     sensorTouch)

#define SAMPLING_PERIOD 50 /* in ms */

task main()
{
    while( true ){
        nxtDisplayTextLine(0,"p");
        nxtDisplayTextLine(2, "Senso: %d", SensorValue[startStop]);
       wait1Msec(SAMPLING_PERIOD) ;
   }
}


The symptom is that I get the raw sensor value (in my case, either 180 or 1023) instead of the normal sensor value (0/1).
I also noticed that by removing the initial comment, the problem disappeared, as in:

Code:
#pragma config(Sensor, S2,              startStop,     sensorTouch)

#define SAMPLING_PERIOD 50 /* in ms */

task main()
{
    while( true ){
        nxtDisplayTextLine(0,"p");
        nxtDisplayTextLine(2, "Senso: %d", SensorValue[startStop]);
       wait1Msec(SAMPLING_PERIOD) ;
   }
}


I had already used initial comments (before the #pragma directives), but in cases I had only motors, no sensors. I didn't test with other sensors and other ports, though.
Does this also happen with everybody else's configuration? If yes, it should interest the developpers...

G. G.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/