c - Array of pointer to functions, having different number of arguments -


i making simple scheduler executes functions contained in fifo queue.

those functions have same return type int, have different number of int arguments.

i tried implement this way, not seem work. compiler forbids conversion between int(*)() , int(*)(int), int(*)(int, int), or of sort. (arduino sketch compiler)

is there way solve problem, or recommend better way around? thanks!

my code:

typedef int (*fnptr)(); // tried this!  int foo(int var) {     return 0; }  int main() {     fnptr fp = &foo; // error: invalid conversion                       // 'int (*)(int)' 'int (*)()'                       // [-fpermissive]     return 0; } 

you can cast:

fnptr fp = reinterpret_cast<fnptr>(foo); 

the ()s "function call operator", adding them makes no sense @ in situation, changes expression "take address of function" "take address of function's return value".

note aboev don't include &, because name of function acts pretty function pointer it's address.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -