[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] calling function pointers via pointers ?
From: |
Joerg Wunsch |
Subject: |
Re: [avr-gcc-list] calling function pointers via pointers ? |
Date: |
Wed, 28 Sep 2005 14:20:40 +0200 (MET DST) |
Vincent Trouilliez <address@hidden> wrote:
> struct menu {
> .....;
> .....;
> int (*fp)()[]; //table to store all the pointers
> };
Better declare them in a prototyped fashion:
int (*fp)(void)[];
> //definition for a menu
> const struct menu __ATTR_PROGMEM__ menu_foo = {
> .....,
> .....,
> {fn1, fn2, ... }
> };
Don't forget to pull out each entry from progmem. It's probably best
to copy over an entire struct menu item at a time using memcpy_P(),
as opposed to copy in each of the struct elements individually.
> //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
Basically yes (I think), but *p needs to be in RAM already.
--
J"org Wunsch Unix support engineer
address@hidden http://www.interface-systems.de/~j/
- Re: [avr-gcc-list] calling function pointers via pointers ?, (continued)
- Re: [avr-gcc-list] calling function pointers via pointers ?, Vincent Trouilliez, 2005/09/29
- Re: [avr-gcc-list] calling function pointers via pointers ?, David Brown, 2005/09/29
- Re: [avr-gcc-list] calling function pointers via pointers ?, Vincent Trouilliez, 2005/09/29
- Re: [avr-gcc-list] calling function pointers via pointers ?, David Brown, 2005/09/29
- Re: [avr-gcc-list] calling function pointers via pointers ?, Vincent Trouilliez, 2005/09/29
- Re: [avr-gcc-list] calling function pointers via pointers ?, Vincent Trouilliez, 2005/09/29
- Re: [avr-gcc-list] calling function pointers via pointers ?, Andy Warner, 2005/09/29
- Re: [avr-gcc-list] calling function pointers via pointers ?, Vincent Trouilliez, 2005/09/29
- Re: [avr-gcc-list] calling function pointers via pointers ?, Anton Erasmus, 2005/09/30
- Re: [avr-gcc-list] calling function pointers via pointers ?, Dave Hansen, 2005/09/29
Re: [avr-gcc-list] calling function pointers via pointers ?,
Joerg Wunsch <=
RE: [avr-gcc-list] calling function pointers via pointers ?, Dave Hansen, 2005/09/28
[avr-gcc-list] Re: calling function pointers via pointers ?, Oleksandr Redchuk, 2005/09/29