- 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
4 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Akshat Dalal
on 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 Comments
More Answers (0)
See Also
Categories
Find more on MISRA C:2012 Directives and Rules in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!