Posts: 1
Threads: 1
Joined: Jan 2010
Reputation:
0
Just to make sure, does rule 16.3 also apply to declarations of function pointers?
void (*pt2Function)(int);
Sould I give a name to the parameter?
Does that make sense at all?
<t></t>
Posts: 632
Threads: 18
Joined: Jan 2006
Reputation:
1
Although the rule is worded in terms of declarations, the intention is that it should apply to all prototypes. A declaration of a function pointer should specify the parameter names, for example:
Code:
void (*pt2Function)(int size);
Any type-casts to function pointer types should also specify the parameter names in the prototype.
Posted by and on behalf of the MISRA C Working Group
Posts: 632
Threads: 18
Joined: Jan 2006
Reputation:
1
The example doesn't violate Rule 16.3 because the prototyped declaration of function
a names its parameter.
However, the code doesn't seem to be valid anyway because:
- pt2Function is declared as an object, not a type in the original example, so cannot be used to declare the object a
- even if pt2Function were a type, a would be declared as an object and then redeclared as a function
Posted by and on behalf of the MISRA C Working Group
Posts: 632
Threads: 18
Joined: Jan 2006
Reputation:
1
Both prototype declarations, pt2Function and b, name their parameters so both are compliant with Rule 16.3.
Posted by and on behalf of the MISRA C Working Group