Thread: Crazy Loops
View Single Post
  #10   Spotlight this post!  
Unread 04-02-2007, 01:28
mluckham's Avatar
mluckham mluckham is offline
Registered User
FRC #0758 (Sky Robotics)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Ontario, Canada
Posts: 116
mluckham will become famous soon enoughmluckham will become famous soon enough
Re: Crazy Loops

Looking only a pseodo-code can lead one to erroneous results.

I once worked on a project where every module was coded, and had to have COMPLETE pseudo-code in the file header as well. Endless hours were spent making sure the two lined up.

Of course the programmers only looked at the code, knowing the pseudo-code would sometimes be wrong.


Recently I had a variable that mysteriously changed values, in a loop like yours. This was using MPLAB. Turned out there were two variables with exactly the same name, one in local scope and one in global scope. The compiler never hinted of the conflict (well, that's my story and I'm sticking to it!). Of course the global one was being updated (by an external .C routine) and the local one was read by the printf ... since it was on the stack and there were interrupts in the system, it always contained garbage.