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

Is this right?

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



Joined: 12 Aug 2009
Posts: 40

View user's profile Send private message

Is this right?
PostPosted: Thu Dec 10, 2009 9:25 am     Reply with quote

Is this right? Notice the text in bold letterring the " cprm= cprm = "

if (rx_ad==44) {crpm=crpm=make16(buffer[2],buffer[1]); //store req spd buffer

I usually program in various forms of C, so this caught me off guard. Is there any esoteric reason exclusive to this compiler, why this is?

Or is this a standard misteak?

This is not my code. I'm in the middle of a rewrite, taking only the parts that work.

Thanks
L. Confused
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 10, 2009 9:40 am     Reply with quote

That looks like a bug, but I am not a C expert, maybe it is a shortcut for writing something, but it does look dubious.
Ttelmah
Guest







PostPosted: Thu Dec 10, 2009 9:40 am     Reply with quote

No reason.
Won't do any harm (in C, you can perform multiple assignments on a single line, and they propogate right to left). The optimiser will probably get rid of the duplicate, but it is almost certainly just a typing error.

Best Wishes
lecutus



Joined: 12 Aug 2009
Posts: 40

View user's profile Send private message

PostPosted: Thu Dec 10, 2009 10:35 am     Reply with quote

I guess in retrospect it doesn't make sense to send an amount to a variable and then to the same variable.

For the record the optimiser didn't get rid of it. This code has been worked on quite a bit. For some reason it's considered a legal statement.

Thanks for the answers.

L.
Ttelmah
Guest







PostPosted: Thu Dec 10, 2009 11:29 am     Reply with quote

It is perfectly legal in C. If you have a number of variables, you can have:

a=b=c=d

and the value of 'd' will propogate right to left (as I originally pointed out). So it won't cause a problem, but will just involve moving the data twice. The fact that the second move involves moving the data from itself to itself, is what I rather hoped the optimiser might remove. The later CCS compilers normally do remove things like this, but presumably here, the code is so 'explicit', that the optimiser doesn't get rid of it....

Best Wishes
lecutus



Joined: 12 Aug 2009
Posts: 40

View user's profile Send private message

PostPosted: Thu Dec 10, 2009 12:51 pm     Reply with quote

Thanks T.

That little trick, a=b=c=d, may come in handy some day.

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