Quote:
Originally Posted by tlewis
And at the end of your driving() routine, the line:
if (gyroe=true){
likely doesn't do what you want.....it does not test to see if the value of "gyroe" is "true", but assigns the value "true" to the variable "gyroe", then evaluates the result -- which will ALWAYS be true. What you want is:
if (gyroe==true){
You can catch these errors at compile time if you write it this way:
if (true == gyroe){
because then if you forget one of the equal signs, then you are attempting to assign a value to the constant "true", which the compiler will flag as an error. I learned that the hard way. More than once. 
|
Most modern compilers (though I don't recall whether the gcc used by Wind River is one of them) will give you a warning when you do "if (x = 1)" instead of "if (x == 1)". It is generally considered good practice to have code that doesn't generate any compiler warnings, and you will avoid errors such as these. I generally turn the warning level all the up as well, to avoid even more errors.