I was just going through some C code, when I got stuck upon this piece of code.
void someFunction(Int32 someVariable)
{
/* someVariable is hard coded to 2 */
(void)someVariable;
//some processing that has nothing to do with someVariable.
}
What does the author meant by the comment, “someVariable is hard coded to 2“?
What exactly is happening to someVariable?
It means that the code used to look like this, for example:
and the author changed it to this:
So, what happened is:
In other words, the code of someFunction now behaves the way the original code behaved when someVariable was 2. You describe the body of someFunction as “some processing that has nothing to do with someVariable”, but, in fact, it is processing that uses 2 for the variable of someVariable. Whatever role someVariable played in the function has been lost by the editing, but, presumably, this code behaves like the old code did, as long as someVariable was 2.