Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 16.4
#2
Lundin Wrote:"16.4 The identifiers used in the declaration and definition of a function shall be identical."

[...]

So as far as I understand it, rule 16.4 would only apply when the names in the function definition and the declaration are different, ie the scenario where the function definition is "apples" but the function declaration is "bananas" (although their parameters and return types are identical, as covered by rule 8.3):

[...]

So I fail to see the point of rule 16.4, it seems redundant to me.

The identifiers in question here are the names of the parameters. It is to prevent you doing this:

Code:
/* x.h */

void x(T a, T b);

/* x.c */

void x(T b, T a)
{
    /* ... */
}

Here I have swapped two identifiers, which could be quite confusing. I could have simply misspelled them. Either way you run the risk of a parameter not being what you think it is.

Is this a big cause of software faults? Not that I've noticed. But it doesn't seem like a terrible rule.

stephen


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)