[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] Table of function pointers
From: |
Jon Bertrand |
Subject: |
RE: [avr-gcc-list] Table of function pointers |
Date: |
Thu, 3 May 2001 08:29:20 -0600 |
You have some stuff I'm not familar with.
Here is how I do arrays of pointers to functions:
/* prototypes for the actual functions */
void Cmd1(TByte bCmd);
void Cmd2(TByte bCmd);
void Cmd3(TByte bCmd);
/* the actual functions all must match the type TFunctionPtr */
typedef void (*TFunctionPtr)(TByte bCmd);
/* the array */
const TFunctionPtr CommandArray[] =
{
Cmd1,
Cmd2,
Cmd3
};
/* how to call a function */
main()
{
CommandArray[bIndex](bParameter);
}
Jon B.
> -----Original Message-----
> From: Guy Robinson [mailto:address@hidden
> Sent: Wednesday, May 02, 2001 3:43 PM
> To: address@hidden
> Subject: [avr-gcc-list] Table of function pointers
>
>
> Hi,
> Can anyone explain what this error means? See source below. I
> can't see what
> I'm doing wrong. Thanks in advance for your help.
>
> Guy
>
> hx_2313.c:37: declaration of `FunctionTable' as array of functions
> hx_2313.c:37: Tree check: expected class 't', have 'x' (error_mark)
> confused by earlier errors, bailing out
> D:\AVRGCC\BIN\MAKE.EXE: *** [hx_2313.o] Error 1
>
>
> #include <io.h>
> #include <progmem.h>
>
> #define pint int __attribute__ ((progmem))
>
> void function0();
> void function1();
>
> pint *FunctionTable[2]() = {function0,function1};
>
> char a,b,index;
>
> void function0(){
> a =b;
> }
> void function1(){
> b =a;
> }
>
> void main(void){
>
> PRG_RDB(FunctionTable[index]()); // call function from
> table at index
> index++;
> }
>
>
>
>
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://avr.jpk.co.nz/mailman/listinfo/avr-gcc-list
>