Pointer to an array of function pointers

int (*rdPtrList[4])(unsigned int addr, unsigned int data); 

The above array is an array of 4 pointers in size for functions that return an int and accepts two unsigned ints. I would like to make a pointer to this array. Is this possible in C?

+4
source share
3 answers

Ah, cunning cunning !!!

I think it works

 int (*(*rdPtrList)[4])(unsigned int addr, unsigned int data); 

because the compiler tells me that _countof(*rdPtrList) is 4.


(I wish you could just say int function(unsigned int addr, unsigned int data)[4]* , as you can in D, this is much more readable: it will be a "pointer to an array of functions".)

+6
source

Leaving the options to read as follows:

  p - p
        * p - is a pointer
       (* p) [4] - to a 4-element array
      * (* p) [4] - of pointers
     (* (* p) [4]) () - to functions 
 int (* (* p) [4]) ();  - returning int. 
+13
source

Try the following:

 typedef int(*rdPtrList_t[4])(unsigned int addr, unsigned int data); rdPtrList_t *ptrToArray; 
+4
source

Source: https://habr.com/ru/post/1346990/


All Articles