Search code examples
cmatlabcode-generationsimulink

Resolve Compilation Errors of Simulink C-Code in matlab function: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token


Following up the Matlab/Simulink tutorial at https://de.mathworks.com/help/simulink/ug/incorporate-c-code-using-a-matlab-function-block.html

A basic c-code shall be put into a matlab function block. Compiling the Simulink model leads to the following error message:

C:\Users...\Matlab\slprj_slcc\6BPyb7AdG47rnTRBAilVFG\customcode_6BPyb7AdG47rnTRBAilVFG.c:4:9: error: expected '=', ',', ';', 'asm' or 'attribute' before '.' token doubleIt.c ^

I am using the MinGW Compiler with Matlab/Simulink. Bit puzzled of where to look for error-fixing, as it SEEMS to be exactly the tutorial written down.

Any idea of how to fix it?


Solution

  • In Simulink's Configuration Parameters Dialogue, the header- and source file was specified at the wrong input-registers (due to trial-and-error). The header file was inserted mistakenly at the "Insert custom C code in generated: Source File" position. Thus giving Simulink incorrect inputs for header and source file.