From Technical Support:
In MATLAB/Simulink, the Enumeration elements reside within their own class definition and are considered separate sets of entities. Because of this, two Enumeration elements in different classes can have the same name.
However, when these Enumeration elements are converted to C, they are converted from respective class properties to basic enumeration types. All entities of enumeration type in C are public in the global namespace. Because these entities are now in the same namespace, two entities with the same name will cause a redeclaration error. The following link provides more information regarding this behavior in C:
In order to avoid this error automatically, please enter the following code in the class definition of the Enumeration types:
methods (Static = true)
function retVal = addClassNameToEnumNames()
retVal = true;
end
end
This tells the Simulink Coder to prefix the Enumeration elements for that Enumeration type with its class name in the generated C code. Therefore, the naming conflict is resolved. More details about the 'addClassNameToEnumNames' function can be found at the following documentation link:
Additionaly, if the two Enum types are defined in the data dictionary of your model as 'Simulink Enumerated Type', by clicking on the Name of the objects from the Model Explorer and enabling 'Add Class Name To Enum Names', the issue should be solved too.