Changes

KFLOP C Programs

1,097 bytes added, 16:23, 22 September 2018
Common C Programming Mistakes
}
</pre>
 
==Common C Programming Mistakes==
A common programming mistake is to forget to add the '()' for a function call.  It might not be obvious why this isn't flagged as an error.  In some programming languages such as Basic a subroutine with no parameters can be called by coding the name with no parenthesis.  In C the name of a function represents the address of the function. Adding the () is required to make a function call to that address.
 
Furthermore in C any valid expression is allowed. For example:
 
2+2;
 
is a valid C expression. The compiler computes 4 and does nothing with it (sometimes computing things have side effects and therefore have purpose).
 
 
2;
 
is a valid C expression. The compiler computes 2 and does nothing with it.
 
 
ClearStopImmediately;
 
is a valid expression. The compiler computes the address of the function ClearStopImmediately and does nothing with it.
 
 
Note we are working on a new code Validation tool (using splint.exe) that will analyze code, detect no useful purpose, and provide warnings in these types of cases. Look for it in the next Version 4.35.
Bureaucrat, administrator
469
edits