28-10-2013, 05:55 PM
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?
Welcome to the new MISRA discussion forum, if you were previously a member of our forums you may need to reset your password.
Last example for rule #13.6?
|
28-10-2013, 05:55 PM
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?
12-12-2013, 09:11 AM
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.
Posted by and on behalf of the MISRA C Working Group
|
« Next Oldest | Next Newest »
|