MATLAB: Potential conflicting usages of identifier error in code generation for a reusable function

codegenconflictEmbedded Coderidentifierlibrary

I am attempting to generate code for a library block that is reused in multiple models in a model reference hierarchy. Why am I getting the error 'Potential conflicting usages of identifier'?
Potential conflicting usages of identifier '<identifier_name>': a global identifier from '<model_reference_A>’. and a global identifier from '<model_reference_B>'
This conflict may be resolved by either increasing the maximum identifier length on the Identifiers pane of the Configuration Parameters dialog box or by changing the name of the conflicting identifier.

Best Answer

If you select Reusable function for the Function packaging parameter and there are multiple instances of the reusable subsystem in a model reference hierarchy, in order to generate reusable code for the subsystem, File name options must be set to Auto.
If the library subsystem's "Function name" or "File name" options are set to "user specified" when generating code, both instances of the subsystem in the top-level model will try to have the same function/file names, which creates a conflict that cannot be resolved by changing the name mangling parameter.