[Top][All Lists]

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

RE: [avr-gcc-list] pointer to functions

From: tibor . harsszegi
Subject: RE: [avr-gcc-list] pointer to functions
Date: Tue, 15 Apr 2003 11:37:59 +0200


> I need to make a struct with two pointers called init and done.

To define the struct:

typedef struct {
  void * Init;
  void * Done;
} tFuncStruct;

To fill it up if it's constant and put it into the EEPROM:

const tFuncStruct myfunctionstruct __attribute__ ((section (".eeprom"))) = 
{foo_bar_Init, foo_bar_Done};

void foo_bar_Init(int arg1, char *arg2, ....)

void foo_bar_Done(short arg1, unsigned char arg2, ....)

To call them:

typedef void (*tInit) (int arg1, char *arg2, ....);
typedef void (*tDone) (short arg1, unsigned char arg2, ....);

   tInit myinit = myfunctionstruct.Init;
   tDone mydone = myfunctionstruct.Done;

   myinit(0, "Hello world!", ....);
   mydone(-1, 0xFF, ....);



reply via email to

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