How can I list my 'InternalData' enumerated data type using Code Descriptor in Embedded Coder R2025b?

I have defined my own enumerated data type with 4 enumerated values in Embedded Coder R2025b. Two of the enumerated values are used in my model where I use CompareToConstant blocks. The enumerated data types are being used as "InternalData". I would like to use Code Descriptor to figure out if an enumerated type is used anywhere in the model, including as "InternalData". When I run the "getDataInterfaces" command as seen below, Code Descriptor returns the base type (uint16) instead of the enumerated data type:
>> cd = coder.getCodeDescriptor('ExampleModel');
>> cd.getDataInterfaces('InternalData').Type
 Why is this command showing the base type "uint16" instead of the enumerated type?

 Réponse acceptée

This behavior is expected and is caused by Embedded Coder code generation optimizations. This behavior does not reflect a modeling or data type issue. 
When optimizations are enabled, enumerated data types that are used only internally may be reduced to their underlying integer base type (for example, “uint16”) during code generation. Code Descriptor represents the data used in the generated code and therefore reflects the optimized integer base type rather than the original enumerated type definition. 
As of MATLAB R2025b, Code Descriptor reports data interfaces after optimization, so enumerated types used as “InternalData” may appear only as their base types in the “Type” property.
Workaround
To confirm whether the enumerated type is captured by Code Descriptor:
  1. Open the Configuration Parameters dialog for the model.
  2. Navigate to Code Generation > Optimization.
  3. Set all code generation optimization settings to their minimum or disabled values.
  4. Regenerate code for the model.
  5. Re-run “coder.getCodeDescriptor” and “getDataInterfaces”.
With optimizations minimized, Code Descriptor preserves higher‑level type information, and the enumerated data type is reported instead of the base type. For more information on how optimizations affect the model and generated code, please see the MathWorks documentation on Code Generation Optimizations. 

Plus de réponses (0)

Catégories

En savoir plus sur Deployment, Integration, and Supported Hardware dans Centre d'aide et File Exchange

Produits

Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by