16.3 - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4) +--- Forum: MISRA-C: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17) +---- Forum: 6.16 Functions (https://forum.misra.org.uk/forumdisplay.php?fid=47) +---- Thread: 16.3 (/showthread.php?tid=824) |
16.3 - beckschulze - 15-04-2011 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? Re: 16.3 - misra-c - 20-04-2011 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. Re: 16.3 - gs - 23-05-2012 So, would the following code, built upon the original example, be in violation of the rule? Code: pt2Function a; Re: 16.3 - misra-c - 25-05-2012 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:
Re: 16.3 - gs - 25-05-2012 Good point. Consider, however, the following: Code: typedef void (*pt2Function)(int stuff); Re: 16.3 - misra-c - 27-05-2012 Both prototype declarations, pt2Function and b, name their parameters so both are compliant with Rule 16.3. |