CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

assignment inside relational expression quick question

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
logical



Joined: 21 Dec 2009
Posts: 57
Location: SouthPort, UK

View user's profile Send private message Visit poster's website

assignment inside relational expression quick question
PostPosted: Wed Jun 30, 2010 3:52 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jun 30, 2010 4:03 pm     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Wed Jun 30, 2010 4:12 pm     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Wed Jun 30, 2010 4:20 pm     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Wed Jun 30, 2010 11:18 pm     Reply with quote

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. Confused

Rohit
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group