Propeller Tool: Make IF A:= report an error.
Oldbitcollector (Jeff)
Posts: 8,091
This one has gotten me twice now during late night programming sessions..
Any chance that Propeller Tool could spot the following error on compile?
IF A:= instead of IF A ==
I can't think of any reason for the first example except to create aggravation
OBC
Any chance that Propeller Tool could spot the following error on compile?
IF A:= instead of IF A ==
I can't think of any reason for the first example except to create aggravation
OBC
Comments
and it will do three things:
1: Perform a call to operation()
2: Assign the return value from operation() to a
3: If a is different from zero then do_something() will be performed.
So it's a short form of
a = operation();
if (a) {do_something();}
Granted, that's error prone in C too.. so some compilers, including GCC, will produce a warning unless you explicitly tell it that yes, you meant '=' and not '=='. So the above should be written as follows to avoid a warning:
if ((a = operation()))
Now, the above is all about C.. it may be totally irrelevant if 'if :=a' isn't even legal in Spin, or if it works differently. I guess I should simply load up a test program in my QuickStart.
-Tor
I doubt if the Prop tool will ever have a warning feature like that, but maybe someone could write a Spin checker utlity. Another useful thing to check for is whether variables are used consistently between the calling program and the method that is called. This would help catch errors with pointers and floating point values.
-Phil
-Tor
-Phil
:= Is an assignment operator and,
== is a comparison command
I have had countless programs messed up by accidentally forgetting about that. Now i just check the whole program over looking for those commands specifically, to know if that was the cause of the error. And a lot of the time, it is.