Community
Participate
Working Groups
Configuring a function pointer with the address of a function only seems to work if the function signature does not contain any UInt16 arguments. If the function signature contains one or more UInt16 arguments, the following error is reported (XDC 3.16.02.32): ----------------------- package/cfg/log_xem3.c", line 3455: error: declaration is incompatible with "void ti_uia_stm_LoggerSTM_writeMemoryRange__E(ti_uia_stm_LoggerST M_Handle, xdc_runtime_Types_Event, xdc_UInt32, xdc_IArg, xdc_IArg, xdc_IArg, xdc_IArg, xdc_UInt16)" (declared at line 408 of "C:/UIA_work/ti/uia/stm/LoggerSTM.h") 1 error detected in the compilation of "package/cfg/log_xem3.c ----------------------- Changing the last argument type to either UInt32 or IArg allows the project to compile without errors. Here's how the function pointer is declared: in ti/uia/runtime/LoggerTypes.xdc: typedef Void (*LogMemoryRangeFxn)(Ptr, Types.Event, UInt32, IArg, IArg, IArg, IArg, UInt16); in the .xdc file of the module to be configured: config ti.uia.runtime.LoggerTypes.LogMemoryRangeFxn loggerMemoryRangeFxn = null; in the .xdc file of the module that contains the implementation of the function: instance: @DirectCall Void writeMemoryRange(xdc.runtime.Types.Event evt, UInt32 snapshotId, IArg fileName, IArg LineNum, IArg fmt, IArg startAdrs, UInt16 lengthInMAUs); in the .xs file that assigns the function address to the function pointer: var cn = mod.common$.logger.$orig.$module.$name.replace(/\./g, '_'); ... mod.loggerMemoryRangeFxn = $externFxn(cn + '_writeMemoryRange__E'); or in the .cfg file that assigns the function address to the function pointer: LogSnapshot.loggerMemoryRangeFxn = $externFxn(ti_uia_stm_LoggerSTM_writeMemoryRange__E);
$externFxn("foo") can only be used to declare the specified function, foo, as follows: extern void foo(); The errors below suggest that the compiler is refusing to allow the assignment of this type of function pointer to a function pointer of type (void *(ti_uia_stm_LoggerST M_Handle, xdc_runtime_Types_Event, xdc_UInt32, xdc_IArg, xdc_IArg, xdc_IArg, xdc_IArg, xdc_UInt16)) To ensure an exact type match in the generated C file, you can use the following syntax: var LoggerSTM = xdc.module("ti.uia.stm.LoggerSTM"); LogSnapshot.loggerMemoryRangeFxn = LoggerSTM.writeMemoryRange; If the function is _not_ defined by a module (e.g., defined in your application's C code), you can use the following: LogSnapshot.loggerMemoryRangeFxn = "&nameOfMyCFunction";