Configuration of function pointer fails [message #534837] |
Thu, 20 May 2010 13:30 |
Brian Cruickshank Messages: 19 Registered: September 2009 |
Junior Member |
|
|
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:
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);
Is this a known problem? Should I file a problem report on this?
Regards,
Brian
[Updated on: Wed, 16 June 2010 17:48] Report message to a moderator
|
|
|
|
Re: Configuration of function pointer fails (solved) [message #540620 is a reply to message #534837] |
Wed, 16 June 2010 17:45 |
Brian Cruickshank Messages: 19 Registered: September 2009 |
Junior Member |
|
|
Found the problem. The line
mod.loggerMemoryRangeFxn = $externFxn(cn + '_writeMemoryRange__E');
should have been
mod.loggerMemoryRangeFxn = $externModFxn(cn + '_writeMemoryRange__E');
From Sasha:
When you are assigning a function to a parameter, that function could be declared in a module or it could be a non-RTSC function. In the first case, you use $externModFxn to signal to the config that the function is already declared and that it doesn't have to be declared again in the big C file. In the second case, the declaration in the big C file is required and you should use $externFxn.
The whole point of that is type checking. The type of the config parameter and the function assigned to it must match.
Thanks to Todd and Sasha for the help.
Regards,
Brian
[Updated on: Wed, 16 June 2010 17:47] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.06482 seconds