View previous topic :: View next topic |
Author |
Message |
logical
Joined: 21 Dec 2009 Posts: 57 Location: SouthPort, UK
|
assignment inside relational expression quick question |
Posted: Wed Jun 30, 2010 3:52 pm |
|
|
Hi Guys/Gals,
When I compile I get a warning of "assignment inside relational expression"
what I am wondering is will this still work or would I be better off re-coding it.
The lines starting with a * are the ones that the compiler complains about
Code: |
has_value_been_found=false; //set this to default false, the following loop will change to true when the value has been calculated
if (lambda_amplification_mode=17)
{
* while (has_value_been_found==false)
{
if (vua_volt>vua_adc_const17[lambda_lookup])
lambda_lookup+=1;
else if (vua_volt=vua_adc_const17[lambda_lookup])
has_value_been_found=true;
* else if (vua_volt<vua_adc_const17[lambda_lookup])
lambda_lookup-=1;
has_value_been_found=true;
}
}
else{
while (has_value_been_found==false)
{
if (vua_volt>vua_adc_const8[lambda_lookup])
lambda_lookup+=1;
else if (vua_volt=vua_adc_const8[lambda_lookup])
has_value_been_found=true;
* else if (vua_volt<vua_adc_const8[lambda_lookup])
lambda_lookup-=1;
has_value_been_found=true;
}
}
}
|
Not asking anyone to do this for me but just a point in the right direction or hint would be more than appreciated.
Thanks
Chris _________________ www.SmallDisplays.co.uk due to lack of time, the domain will more than likely be for sale, pm me if interested |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jun 30, 2010 4:03 pm |
|
|
Quote: | if (lambda_amplification_mode=17) |
This will always be true. 17 is a non-zero value, so the expression will
be evaluated as True.
Are you sure you didn't really intend to check for equality to 17 ?
This is done with a '==' operator.
You have the same problem in two other places. |
|
|
logical
Joined: 21 Dec 2009 Posts: 57 Location: SouthPort, UK
|
|
Posted: Wed Jun 30, 2010 4:12 pm |
|
|
PCM programmer wrote: | Quote: | if (lambda_amplification_mode=17) |
This will always be true. 17 is a non-zero value, so the expression will
be evaluated as True.
Are you sure you didn't really intend to check for equality to 17 ?
This is done with a '==' operator.
You have the same problem in two other places. |
Bugger, you are totally correct, that should have been a double ==, have messed that up trying to find out the cause of the "assignment inside relational expression" on the 2nd and 4th else if.
As per usual PCM, thank you for a prompt reply. _________________ www.SmallDisplays.co.uk due to lack of time, the domain will more than likely be for sale, pm me if interested |
|
|
logical
Joined: 21 Dec 2009 Posts: 57 Location: SouthPort, UK
|
|
Posted: Wed Jun 30, 2010 4:20 pm |
|
|
logical wrote: | PCM programmer wrote: | Quote: | if (lambda_amplification_mode=17) |
This will always be true. 17 is a non-zero value, so the expression will
be evaluated as True.
Are you sure you didn't really intend to check for equality to 17 ?
This is done with a '==' operator.
You have the same problem in two other places. |
Bugger, you are totally correct, that should have been a double ==, have messed that up trying to find out the cause of the "assignment inside relational expression" on the 2nd and 4th else if.
As per usual PCM, thank you for a prompt reply. |
And again, thanks for the hint, found the other two errors (missing =='s)
All problems gone and the whole project compiles without errors or warnings.
Probably mush have gone bozeyed looking at the screen for too long.
Thank to CCS Forum & PCM in particular. _________________ www.SmallDisplays.co.uk due to lack of time, the domain will more than likely be for sale, pm me if interested |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Wed Jun 30, 2010 11:18 pm |
|
|
Quote: | The lines starting with a * are the ones that the compiler complains about | A tip in troubleshooting is that CCS (and other C compilers) flag an error when it encounters something that it doesn't like. Sometimes the compiler stops at the next line after the error, but quite often, the error will be some line _above_ the line indicated by the compiler.
Rohit |
|
|
|