Rule 16.5 - 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: Rule 16.5 (/showthread.php?tid=838) |
Rule 16.5 - hanthen - 02-08-2011 Does this rule apply also to function pointers? If I want to declare a function pointer which can be used for pointers to functions with different arguments, something like the following is useful: uint8_t (* gen_u8p)(); Is this intended to be prohibited by the rule? Re: Rule 16.5 - misra-c - 09-08-2011 No, rule 16.5 does not apply to function pointers. However, note that:
Therefore, a pointer to a non-prototyped function cannot be used to call a function and cannot be converted to a pointer that could be used to call a function. The rationale is to avoid the undefined behaviour that occurs when a function is called by means of a pointer whose type is not compatible with the called function. |