- https://www.mathworks.com/help/coder/ug/pass-structure-arguments-by-reference-or-value.html
- https://www.mathworks.com/help/simulink/sfg/integrating-existing-c-functions-into-simulink-models-with-the-legacy-code-tool.html#bq4g1es-4
How to generate C function to return a bool
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am using Simulink Coder v23.2 (R2023b) 01-Aug-2023.
I would like to generate C code for a function to return a boolean value; I am unable to make it do that.
For example:
variable retval is of type boolean, and scope Output.
The code that is generated is:
void isSensorActive(bool *retval)
{
*retval = (MY_DW.sensorActive == 85ULL);
}
What I want is for the function to actually return a bool.
Something like:
bool isSensorActive(void)
{
return (sensorActive == 85ULL);
}
How do I make Simulink generate a function to return a boolean?
Thank you for any suggestion you can provide.
0 Kommentare
Antworten (1)
Raghava S N
am 14 Mär. 2024
Hi Duane,
From the second attached code snippet (the desired generated code), I assume that the intended functionality is to have the functions generated during code generation “pass by value”.
This feature can be enabled for the either the top model in the current model hierarchy or the current referenced model.
In the Model Configuration Parameters, under the Model Referencing tab, expand the Advanced Parameters option. The check box for “Pass fixed-size scalar root inputs by value for code generation” should be enabled to use this feature.
Please refer to this link for more information - https://www.mathworks.com/help/simulink/gui/passfixedsizescalarrootinputsbyvalueforcodegeneration.html.
Some additional documentation that may be of help –
Best Regards,
Raghava
0 Kommentare
Siehe auch
Kategorien
Mehr zu Simulink Coder finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!