AST --> CGScope Error When Using Custom Code
显示 更早的评论
I created a .cpp file and compiles with g++ in terminal and the executable runs fine.
However, when I add the .cpp file and its dependencies (compiler, include, header, library files) in the Simulink custom code configuration, it returns:
Failed to convert AST --> CGScope
There is no other information available in the diagnostic viewer.
回答(1 个)
David Balbuena
2025-1-2
0 个投票
You're hitting a bug with the parser that Simulink uses to parse through all symbols in your header file. If you are able to share your code, you can contact MathWorks Technical Support to report the bug: Contact Support - MATLAB & Simulink
You can workaround it by writing a wrapper .cpp/.h file and providing the wrapper to Simulink. You can see an example of that here: Call C++ Class Methods Using C-Style Wrapper Function from C Function Block
The example uses C Function block, but you can apply this style to C Caller block as well.
类别
在 帮助中心 和 File Exchange 中查找有关 Simulink Coder 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!