|
From: | Dan Roganti |
Subject: | [avr-gcc-list] Problem with avr gcc compiler ? No warning of mixed data types |
Date: | Sun, 19 Apr 2009 11:25:42 -0400 |
User-agent: | Thunderbird 2.0.0.21 (Windows/20090302) |
Justed wanted to forward something of an experience we had trying to debug the last code for our robot. I recently had a annoying bug in the code for our robot project. This involved using the ADC which is connected to the GP2D12 sensors. I have the code written using interrupts to read each sensor. Everything works fine using a simple test code (also using interrupts) to check each sensor.This was just a simple test by pressing one of the switches on the controller- one for each sensor -- to check the reading. When I moved this test code into the application code for the robot, I added a buffer --using an array variable -- to store the readings for later. However this continually failed to operate correctly. The compiler never showed any warnings for this issue - and of course no errors since I was able to download the code to run this on our robot. We spent a long time trying to decipher why the sensors in the test code would work but not in the appl code. Eventually, we noticed a problem with the data types getting mixed, the adc value is stored in a uint16_t variable and the array which holds all the readings was a uint8_t variable. This obviously mashed all the readings into something unreliable. This is something we should have noticed, but _also _ something that the *compiler* should have noticed ! I mean the compiler gives some of the most stupid warnings, such as , when a function that is declared but not used (who cares - I know that already since I'm coding this) I wonder what else is not being checked. =Dan -- [ = http://www2.applegate.org/~ragooman/ ] |
[Prev in Thread] | Current Thread | [Next in Thread] |