I have some c code that is wrapped in an s-function using legacy_code().
The S-Function has to call c initialisation function void init_Code();
def.StartFcnSpec = ['void init_Code(void)'];
legacy_code() generates the sfunction withought error.
I then add some bus input/outpt to the sfunction and then generate a PIL block out of that so I can deploy it to a microcontroller. If I don't set the StartFcn this works prefectly fine.
With the StartFcn I get compilation error.
undefined first referenced
symbol in file
error: unresolved symbols remain
error: errors encountered during linking; "sfunksCode.out" not built
Note that the undefined symbol has a leading underscore ( _ ) before the function name.
I had a look at the generated c code and there is no "_init_Code" anywhere in any of the generated files.
The s-function initialisation block looks fine:
44 /* Model initialize function */
45 void sfunksCode_initialize(void)
47 /* Registration code */
49 /* initialize error status */
50 rtmSetErrorStatus(sfunksCode_M, (NULL));
52 /* external inputs */
53 sfunksCode_U.input = sfunksCode_rtZsfunkCodeBUS;
55 /* external outputs */
56 (void) memset(&sfunksCode_Y.output, 0,
59 /* Start for S-Function (customCode): '<Root>/customCode' incorporates:
60 * Inport: '<Root>/ input'
61 * Outport: '<Root>/output'
Notice the init function is correctly called.
And this only happens at the linker stage ie all the sources compile fine.
I also created another function named _init_Code() which just calles my original init function to see if that would do as a work around, however I get the exact same error.
I'm guessing Coder is doing something exciting and helpful that I need to switch off?
**Edit: Further investigation suggests that this might be related to the specific micro controller which is a TI C2000 Delfino