AST --> CGScope Error When Using Custom Code

2 次查看(过去 30 天)
I'm trying to integrate the Pinocchio with Simulink for some robot development work.
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 个评论
Haowen
Haowen 2024-12-26
FYI: I can compile using mex on my source .cpp file and run the generated mexa64 files in the MATLAB command window. When I setup the c caller or c function block in Simulink, it alwasy returns Failed to convert AST --> CGScope.
Can Mathworks staff give more insight on this error message? There is no other error shown in the diagonostic viewer.

请先登录,再进行评论。

回答(1 个)

David Balbuena
David Balbuena 2025-1-2
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.

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by