Quote:
|
Originally Posted by velocipenguin
I think you missed the point.
The reason C compilers don't typically give warnings or errors for using the single equals sign inside a conditional is because it CAN be valid. In the code I posted, the single equals sign sets the address of a file handle, whose value needs to be inequal to zero in order to work. Yes, it's one of those annoying tricks used by programmers who like being clever (i.e. me), but my point is that it's valid and there's no reason the compiler should label it as a syntax error.
|
You're right in that no compilers will list this as a syntax error. However, every C compiler that I have used (up until the compiler for the IFI RC) will give a warning for the type of statement that you describe using the default warning settings.
If you are using a new compiler, one of the first things you should do is see how the warning levels are set, and then set them to how you like them.
As people have been finding out, C allows a lot of "strange" things as valid syntax, which is done to increase flexibility and the speed of the language. However, this can lead to some confusing run-time errors. This is why C compilers have warning messages in addition to error messages. If you use the warnings properly, you shouldn't have much issue.
Another point: C is like anything else in life: you're not going to be good at it until you practice with it. You'll make errors, you'll find the errors, and then you'll start learning where to look for future errors. In the future, you'll begin to recognize certain behaviors that will help you pinpoint the errors. You know, "hey, I've seen this type of thing before".
Just because you've all hit a few stumbling blocks on your first attempt at C doesn't mean it's a bad language. It just means you're not used to it. Give it a little time and you'll soon be wondering how we ever survived with pBASIC.
Also: Has everyone been taking advantage of signed math? I sure hope so. It is probably the biggest advantage of the new C compiler vs. the old pBASIC controller.