AST --> CGScope Error When Using Custom Code

2 vues (au cours des 30 derniers jours)
Haowen
Haowen le 23 Déc 2024
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 commentaire
Haowen
Haowen le 26 Déc 2024
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.

Connectez-vous pour commenter.

Réponses (1)

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

Catégories

En savoir plus sur Simulink Coder dans Help Center et File Exchange

Produits


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by