[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] calling function pointers via pointers ?

From: Vincent Trouilliez
Subject: [avr-gcc-list] calling function pointers via pointers ?
Date: Wed, 28 Sep 2005 11:53:55 +0200

Hi list,

Another pointer problem again, oops...
I need pointers to functions in my project. Using the great on-line
resource http://www.eskimo.com/~scs/C-faq/q4.12.html which someone on
here mentioned recently, I got the basics working.
But my actual case at hand is a bit trickier and I am lost again (okay,
doesn't take much to loose myself I admit ;-).

Problem: my function pointers are in an array, within a structure, which
itself is accessed via pointers... oh dear.

The essence of my code follows, I need expert advice on how to access
these pointers in order to call the functions...



//data type for a menu
struct menu {
        int (*fp)()[];  //table to store all the pointers

//definition for a menu
const struct menu __ATTR_PROGMEM__ menu_foo = {
        {fn1, fn2, ... }

//run the specified menu using the structure passed as argument
void menu_run(const struct menu * p)
        int r;
        r = (p->fp[0])();       //call the first function
        ....                    //syntax ???....

reply via email to

[Prev in Thread] Current Thread [Next in Thread]