Anu Radha

How to handle different functions with function pointers?

Discussion created by Anu Radha on Apr 18, 2008
Latest reply on Apr 22, 2008 by Daniel Lundin
In my program i need to handle different type of functions.I created some structure for accessing different functions.

typedefstruct{
UCHAR (*const GetFunc)(void
);
}
UCHAR_CPMTS;

typedef struct{
UINT (*const GetFunc)(void
);
}UINT_CPMTS;

typedefstruct{
void
(*constSetFunc)(UCHAR);
}
UCHAR_CPMTS_INIT;

typedef
struct{
void
(*constSetFunc)(UINT);
}UINT_CPMTS_INIT;

 

static

const UCHAR_CPMTS UCHAR_GET_FUNC_LIST[] =
{
PROD_SPEC_UCHAR_GET_FUNC_LIST
};
static const UINT_CPMTS UINT_GET_FUNC_LIST[] =
{
PROD_SPEC_UINT_GET_FUNC_LIST
};
static const UCHAR_CPMTS_INIT UCHAR_SET_FUNC_LIST[] =
{
PROD_SPEC_UCHAR_SET_FUNC_LIST
};
static const UINT_CPMTS_INIT UINT_SET_FUNC_LIST[] =
{
PROD_SPEC_UINT_SET_FUNC_LIST
};

#definePROD_SPEC_UCHAR_GET_FUNC_LIST  \

           GetButtonState   \

           NULL


 

using this pointers i can handle only  functions having uchar,uint return types and as arguements.But i need to handle SCHAR, as well as functions with more no of arguements.How to handle them in generic way,Instead of creating one structure for every fuction type.Please help me.I need the solution very urgent.

Thanks,

Anuradha.

Outcomes