Problem with boolean_T type and bool type in generated code

6 Ansichten (letzte 30 Tage)
Benjamin Thompson
Benjamin Thompson am 5 Feb. 2015
I have a Stateflow block in a model that exists in a library. The model is used more than once in the upper level model that I am code generating using ERT. The Stateflow block has some boolean inputs that come from an imported structure definition. The imported structure header file uses the datatype "bool" for these inputs, but of course the equivalent Simulink bus definition needs to use boolean.
The code generator is generating the Stateflow chart as a reusable function that requires the boolean inputs to be passed by address (type boolean_T*). Not sure why I need to pass a boolean as a pointer, but anyway...
The generated code ends up attempting to take the address of the inputs from the imported C data structure (type bool *) and trying to pass these to the function that implements the Stateflow chart (which expects type boolean_T *). My GCC 4.8.2 Redhat 64-bit compiler does not like this situation and will not compile the code.
So you really cannot do a data type replacement of boolean_T to bool? Any ideas about a workaround?
I can take care of this by forcing Simulink to inline the Stateflow diagram. This adds to the complexity of the function that calls the Stateflow diagram, so is not ideal.
  3 Kommentare
Justin Hurst
Justin Hurst am 20 Sep. 2019
Hello Benjamin & Erik ,
Did you guy's find a solution for this , I am also facing the same issue.
Is there any way to solve this issue without changing the Input data type from bool to something else.
Benjamin Thompson
Benjamin Thompson am 20 Sep. 2019
This was four years ago, probably MATLAB R2014 or R2015A. My notes indicated that I inlined the Stateflow block in the model and it did the trick because then the code was no longer using pointers to boolean types.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by