Function pointers are not supported in the .c file.
Posted: Mon Oct 18, 2021 2:02 am
Function pointers are not supported in the .c file. I did a test in /module_i2c_shared/src/i2c_shared.c of the project sw_usb_audio-[sw]_6.15.2 and found that the pointer function cannot be used. The error reported when compiling app_usb_aud_xk_216_mc is as follows:
/home/username/workspace-xmos1/module_usb_audio/main.xc:(.dp.data.4+0x4): Error: Meta information ("i2c_shared_master_init.nstackwords") for function "i2c_shared_master_init" cannot be determined.
/home/username/workspace-xmos1/module_usb_audio/main.xc:(.dp.data.4+0x4): Error: lower bound could not be calculated (function is recursive?).
How to solve this problem?
The test code is:
typedef void (*func_ptr)(void);
func_ptr fPtr;
void* get_func_pointer()
{
return (void*)fPtr;
}
void call_func_pointer(void *f)
{
((func_ptr)f)();
}
void i2c_shared_master_init(REFERENCE_PARAM(struct r_i2c, i2cPorts))
{
//test code
void *x = get_func_pointer();
call_func_pointer(x);
//ori code
...
}
/home/username/workspace-xmos1/module_usb_audio/main.xc:(.dp.data.4+0x4): Error: Meta information ("i2c_shared_master_init.nstackwords") for function "i2c_shared_master_init" cannot be determined.
/home/username/workspace-xmos1/module_usb_audio/main.xc:(.dp.data.4+0x4): Error: lower bound could not be calculated (function is recursive?).
How to solve this problem?
The test code is:
typedef void (*func_ptr)(void);
func_ptr fPtr;
void* get_func_pointer()
{
return (void*)fPtr;
}
void call_func_pointer(void *f)
{
((func_ptr)f)();
}
void i2c_shared_master_init(REFERENCE_PARAM(struct r_i2c, i2cPorts))
{
//test code
void *x = get_func_pointer();
call_func_pointer(x);
//ori code
...
}