Using C++ constructs in Stateflow charts: is it possible?

1 回表示 (過去 30 日間)
fraben
fraben 2022 年 9 月 30 日
コメント済み: fraben 2022 年 10 月 7 日
Hello,
I am generating C++ code from a Simulink model i just received, using Embedded Coder v2021b. In this model there are various stateflow charts: the action language for these is set to C. I tried to use various C++ constructs (pass by reference, classes, namespaces), but they are rejected by the compiler. This is most likely due to the fact that C is the action language, and links such as this one make me think C++ can be only inserted using "workarounds".
Anyway, i ask for confirmation: is there really no way to directly use C++ constructs in Stateflow charts?
As a related question, when the code will be generated (i still haven't tried), will i get C++ or C code? (both the Simulation Target language and the Code Generation language are set to C++)

回答 (1 件)

Santosh Fatale
Santosh Fatale 2022 年 10 月 7 日
Hi Francesco,
I understand that you want to use C++ constructs in stateflow charts. You can call C++ methods using C-Style Wrapper Functions from C Function block. For more details, you can refer below link.
  1 件のコメント
fraben
fraben 2022 年 10 月 7 日
Thank you for the reply Santosh :)
More than being able to call C++ methods, i am wondering if i can use C++ syntax in Stateflow: for example use references (instead of pointers), or invoke static class methods. So far, trying to use these constructs resulted in compiler errors.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeComplex Logic についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by