MISRA Discussion Forums

Full Version: Last example for rule #13.6?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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.