Last example for rule #13.6? - 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:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21) +---- Forum: 8.13 Side effects (https://forum.misra.org.uk/forumdisplay.php?fid=168) +---- Thread: Last example for rule #13.6? (/showthread.php?tid=992) |
Last example for rule #13.6? - gs - 28-10-2013 Try as I might, I cannot get my compiler to recognize the last example for rule #13.6, the example involving an array of function pointers, as well formed. Is this intended? Re: Last example for rule #13.6? - misra-c - 12-12-2013 The example should compile with a conformant C99 compiler. However, trying the following in http://www.cdecl.org might help some readers to understand the declaration. void (*fn)(int) declares fn as pointer to function (int) returning void void (*fn)(int[5]) declares fn as pointer to function (array 5 of int) returning void void (*fn[3])(int[5]) declares fn as array 3 of pointer to function (array 5 of int) returning void so "typedef void (*fntype[3])(int[5]);" would declare a type called fntype which was an "array 3 of pointer to function (array 5 of int)". You can omit the type name when using the type as a parameter to a function or in sizeof, and also you can independently add/omit a parameter name. Using a parameter name "a", this example would give you: void (*[3])(int a[5]) In the document example the [3] and [5] are replaced by two variable length arrays [n] and [v] respectively. |