did Lite_C can use by lw_oopc?
Function pointers
In C/C++, function pointers are declared like this: int (*foo)(int a, int b);. In lite-C there's no difference between function prototypes and function pointers: int foo(int a, int b);. See details under pointers.
Function pointers
Pointers of functions or actions can be defined as FUNCTION* under C-Script. LC Under lite-C a function pointer is defined just as a function prototype with return and parameter types. Example:
float myfunction(int a, float b); // define a function pointer named "myfunction"
float fTest(int a, float b) { return (a*b); }
...
myfunction = fTest;
x = myfunction(y,z);
Can I want to use function pointer in Struct in Lite-C?
typedef struct
{
int _var;
int Add(int a, int b);
}Hello;
int fTest(int a, int b) { return (a+b); }
int ATest(int a, int b) { return (a-b); }
Hello* InitHello(Hello* pHello,void* functionPoint)
{
pHello->Add = functionPoint;
}
void main(){
Hello A;
InitHello(A,ATest);
int Test(int a, int b) ;
Test = A.Add;
printf("%d\n%p\n%p %d",sizeof(A),fTest,A.Add,Test(2,5));
} :eek: