Hello
I've a problem when initializing a global function pointer. Depending on where the function pointer is created, the adress of the funciton pointer is 0 (=wrong). There are no warnings in the compiler! Compiler: c166 v4.23 Tool: uVision2 v2.31
Example:
typedef UINT16 (*pModul_Para)(UINT16, UINT16 *, void *, UINT16);
//prototype of the function UINT16 Controller_Para(UINT16 ParamNr, UINT16 *pElementNr, void *pValue, UINT16 Action);
//create and init the function pointer pModul_Para FunctionPtr123 = &Controller_Para;
//Function definition UINT16 Controller_Para(UINT16 ParamNr, UINT16 *pElementNr, void *pValue, UINT16 Action) { ... }
//create and init a second function pointer pModul_Para FunctionPtr55 = &Controller_Para;
--> Result: FunctionPtr123 would be 0, FunctionPtr55 can be the address of Controller_Para.
Any idea? Thanks!
Hi r k,
How do you get the values of pFunktionPointer_1, pFunktionPointer_2, pFunktionPointer_3?
On the X86 platform, I can simply do this:
int main(void) { printf("pFunktionPointer_1 = %d\n", pFunktionPointer_1); printf("pFunktionPointer_2 = %d\n", pFunktionPointer_2); printf("pFunktionPointer_3 = %d\n", pFunktionPointer_3); system("PAUSE"); return 0; }
But on the C166 platform, How do you get the values?
not sure about C166. but on C51, you just step through the code and watch the pointers.
Most compilers have a %p for printing pointers - potentially with a size flag to specify what type of pointer to print.
I don't use printf or like this. I can see the adress of the pointer in the list file (.m66). So I read the contents of the address via an RS232 communication.
Thank you for the efforts!