How to integrate a C code file generated from m file into stateflow and then generate the C code?

1 次查看(过去 30 天)
It's complex, ha? In the stateflow, I use a m file. And I want to generate the C code. So first I generate the m file to C code, which has been done successfully. But there are several C code files there. Then I want to use coder.ceval to call the C code but errors like this:
comtradeTest_sfun.c c:\code\project\scientific model\codegen\lib\fnmypronylast\rt_nonfinite.h(20) : error C2059: syntax error : '-' c:\code\project\scientific model\codegen\lib\fnmypronylast\rt_nonfinite.h(26) : error C2059: syntax error : 'type' c:\code\project\scientific model\codegen\lib\fnmypronylast\rt_nonfinite.h(28) : error C2059: syntax error : 'type' comtradeTest_sfun.c(13) : error C2143: syntax error : missing '{' before '.' comtradeTest_sfun.c(13) : error C2059: syntax error : '.' NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\amd64\cl.exe"' : return code '0x2' Stop.
Any ideas?

回答(1 个)

Shreshth
Shreshth 2024-6-26
Hey,
To resolve the syntax errors when compiling the generated C code, follow these steps:
1. Inspect the Generated Code: Check the `rt_nonfinite.h` file at the specified lines for any syntax issues.
2. Ensure Compatibility: Verify that the generated code is compatible with your compiler.
3. Update Compiler: Consider using a more recent version of the compiler if you are using an outdated one.
4. Correct Errors: Address specific syntax errors related to misplaced characters or incorrect type declarations.
5. Simplify the Code: Break down the code into smaller parts to isolate and identify the problematic areas.
6. Use MATLAB Coder: Ensure that function signatures and data types match between MATLAB and the generated C code.
7. Consult Documentation and Support: Refer to MATLAB and Simulink documentation or contact MathWorks support for further assistance.
By following these steps, you can troubleshoot and resolve the compilation errors effectively.

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by