- Create a Simulink.AliasType in the base workspace named boolean_t
- Set it's base type to be of type int8
- Reference boolean_t in the data type replacement for boolean under the Configuration parameters -> Code Generation -> Data Type Replacement pane
Local variables are getting generated after code generation using embedded coder and if statement expression is not Boolean type throwing an error after running polyspace
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Mukund
le 23 Jan 2025
Réponse apportée : Akshat Dalal
le 23 Jan 2025
An Image shown below in which guard condition is mentioned whose if statement is non compitant as per MISRA C 2012 Rule 14.4
As per Rule if statement should have boolean type expression.
0 commentaires
Réponse acceptée
Akshat Dalal
le 23 Jan 2025
Hi Mukund,
I faced a similar issue and it was occuring because the underlying data type of boolean_t generated by Embedded coder seems to unsigned char. I was able to get around this by creating an alias for boolean and changing its base type to int8, which changes the underlying data type to signed char.
This should remove the violations while keeping the generated code same as before. The change can be observed in the rtwtypes.h file which gets generated.
Hope this helps. Thanks!
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur MISRA C:2012 Directives and Rules dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!