MATLAB: Using Embedded Coder, how can I customize the typedefs generated in rtwtypes.h
simulink coder
Using Embedded Coder, how can I customize the typedefs generated in rtwtypes.h?
Best Answer
The 'rtwtypes.h' header file generated by Embedded Coder defines the mapping between Simulink data types and primitive C/C++ data types. Embedded Coder makes such decisions based on the word length of target hardware code generation to make sure generated code leads to the same result as in simulation. This file should not be manually edited for customization.
Although you should not manually customize this file, you can still customize your typedefs. In some cases customization is needed so that generated code aligns with coding standards. In this case, use data type replacement.
Data type replacement allows you to import customized data type aliases defined in your own header files and use them to define Simulink data types in generated code. If a Simulink data type is defined with an alias, then its definition in 'rtwtypes.h' is not used. Instead, the compiler goes to the custom header file for the definition.
For more information about data type replacement, please see the following reference:
I don't think you can avoid rtwtypes.h from getting generated because it contains typedefs for platform-independent types. You might be able to do some post-processing on the generated code to replace all platform-independent types like int8_T with the corresponding built-in types for your platform, and discard rtwtypes.h altogether.
You can not replace the datatype names generated by embedded coderwith C-style type names.
But, if you don't like the type name generated by embedded coder (I think MISRA standard in not your friend), you can configure the embedded coder to replace the type names with yourown type names.
For example you can configure embedded coder to generateMy_u16 instead of uint16_T forunsigned int.
Best Answer