Go Down

Topic: if(a=b) is not if(a==b) could IDE check this b4 upload? (Read 6 times) previous topic - next topic



just wanna say that i made a maaaassive noob error today and took like 30 mins to find it

i had an =  instead of an == in an if statement .. . . .

I've done this before and can see myself doing it again, could there be a check run when i hit verify/compile ?  that would save quite some trouble!

just a suggestion :]


The problem is that "if (a=b)" is a perfectly legal statement.  It just that it doesn't do what the programmer expected.
There actually is a compiler switch that will cause this to issue a "warning" statement, but: the warning is likely to appear pretty cryptic to beginning programmers and other warnings that may or may not be relevant are also likely to appear.


Yes, please make the IDE psychic, so that it can read my mind and my program will do what I want instead of what I say:)

Sorry, this is just one of those things you have to learn about C.  Sounds like you've learned it...



That's the oldest gotcha in the C book. Welcome to the club :)

Rob Gray aka the GRAYnomad www.robgray.com


That's the oldest gotcha in the C book. Welcome to the club

Indeed. In my case it's the gift that keeps on giving.  :)

Go Up