[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: |
David Brown |
Subject: |
Re: [avr-gcc-list] calling function pointers via pointers ? |
Date: |
Thu, 29 Sep 2005 09:06:17 +0200 |
> From: Vincent Trouilliez <address@hidden>
> [...]
> >Problem: my function pointers are in an array, within a structure, which
> >itself is accessed via pointers... oh dear.
> >
> [...]
> >//data type for a menu
> >struct menu {
> > .....;
> > .....;
> > int (*fp)()[]; //table to store all the pointers
>
> Err... Read it from the inside-out: fp is a pointer to a function that
> returns an array of pointers to int. I don't think that works, let alone
is
> what you want. And you need to specify the size, and it's a good idea to
> specify the formal parameters needed by the function. I think you mean
> something like
>
> int (*fp[3])(void);
>
> fp is an array of 3 pointers to function taking void and returning int.
>
Just a little hint - use typedef for any types involving more than two
"bits" :
typedef int (*FInt)(void);
struct menu {
...
FInt fp[3];
...
typedefs make the code legible and clear - if you have to think hard or read
comments to understand a type, then the code is wrong (even if it is
right!). IMHO, of course.
mvh.,
David
- 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 ?, 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, 2005/09/28
RE: [avr-gcc-list] calling function pointers via pointers ?, Dave Hansen, 2005/09/28
- Re: [avr-gcc-list] calling function pointers via pointers ?,
David Brown <=
[avr-gcc-list] Re: calling function pointers via pointers ?, Oleksandr Redchuk, 2005/09/29