AST --> CGScope Error When Using Custom Code
Show older comments
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.
Answers (1)
David Balbuena
on 2 Jan 2025
0 votes
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.
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!