Maximum identifier length '31' does not provide sufficient space to make symbol names unique

I am getting the following warning when generating code from my model:
  • Insufficient space for computing symbol names in model 'controller'. The maximum identifier length '31' does not provide sufficient space to make symbol names unique using the symbol format string in 'Global variables'. This is required when using model reference. Consider increasing the maximum identifier length. To eliminate this message enter the command set_param('controller', 'ModelReferenceSymbolNameMessage', 'none') at the MATLAB prompt
I have a similar warning for 'Global types' and 'Subsystem methods'. I believe some names are too long and it does not fit in identifier length '31'.
I do not want to increase the maxmum identifier length because it is required in certain standards. So I want to find and identify which names are too long. How can I find those?

10 Comments

Hi, were you ever able to solve this problem? I am having the same issues and I don't know where to look in the matlab function block to find the issue.
Perhaps you could increase the identifier length and then scan the generated C or C++ code for long identifiers? Some compilers permit turning on warnings or errors about long identifiers to make it easier to check.
Have you tried modifying the identifier settings in the config parameters? Also what are your identifier settings?
I have currently increased the setting of maximum identifier length to 63 instead of 31. I thought some compilers would not like identifiers longer than 31 but for the moment it poses no issue.
Potential conflicting usages of identifier 'Input_IO_CAN_ReadMsg_CleanupRTR': a global identifier from '', and a global identifier from '' 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.
I am receiving this error, even if I change to 63 for Identifier length and the generation is successful I can't find the identifier anywhere so why did it give the error in the first place?
identifier from ''
In the message that you received, was the quoted string empty like you posted, or was there something inside the '' that you removed for privacy purposes?
Of course there was an identifier there and the name of 2 modules where this global symbol identifier is, but I couldn’t find it anywhere in the generated code or the models
Was there something like Input::IO::CAN::ReadMsg::CleanupRTR ?
Are you using CAN messages ?
Hello, like I said I am using CAN messages.
Is there any solution for my problem, outside from making the identifier names longer?

Sign in to comment.

Answers (2)

@Bogdan Bodnarescu
This is not something that I have had to deal with.
I get the impression that you are using model reference to the CAN blocks in two different places in your model, and that CAN blocks have global variables. In such a case, in order to differentiate between the global variables for the different locations, Simulink would try to qualify the variable name with information about where in the model it was occurring -- for example it might take
/Project7/Control Loop/Subsystem1/CAN_Receive/Input::IO::CAN::ReadMsg::CleanupRTR
/Project7/Control Loop/Subsystem1/CAN_Receive/Input::IO::CAN::ReadMsg::MsgLength
/Project7/Control Loop2/Subsystem1/CAN_Receive/Input::IO::CAN::ReadMsg::CleanupRTR
/Project7/Control Loop2/Subsystem1/CAN_Receive/Input::IO::CAN::ReadMsg::MsgLength
and try to create variables
ControlLoop_Subsystem1_CAN_Receive_Input_IO_CAN_ReadMsg_CleanupRTR
ControlLoop_Subsystem1_CAN_Receive_Input_IO_CAN_ReadMsg_MsgLength
ControlLoop2_Subsystem1_CAN_Receive_Input_IO_CAN_ReadMsg_CleanupRTR
ControlLoop2_Subsystem1_CAN_Receive_Input_IO_CAN_ReadMsg_MsgLength
and then it would have a problem that these were not unique with the first 31 characters.
If that is what is happening, then you could proceed in a small number of different ways:
  • Increase the identifier length. MISRA warning about this are warnings that there might come a day when you want to port the code to a device but be unable to because the compilers for the device only support 31 characters (the minimum for C or C++ compliance) -- that the compiler might not even notice that the names are different. This is a hypothetical long-term problem but depending on your needs and business plans it might turn out to be irrelevant completely, or might be something that could be postponed for years until it becomes and actual need; or
  • copy the CAN blocks and change the variable names in the copy; or
  • turn off model referencing, so that these model-referencing messages go away (might cause different problems); or
  • rework your model so that CAN blocks are only used in one place. This could potentially be workable if what you are modeling is a system with a single central point that is processing all the CAN block messages -- but it might not be workable at all if you are modeling a system with multiple consumers of CAN block messages. For example do you have a single central location that is processing a number of messages and making decisions about spin rates for all four tires for 4WD? or do you have one processor for each tire each receiving much the same stream of messages but each making independent decisions about one tire for 4WD ? (Increase the number of drive wheels because it is a tractor or semi trailor, and ask yourself what happens if you have a single processor making decisions and that processor fails or is damaged... having multiple systems making semi-independent decisions might be important in some cases.)

2 Comments

Wow, this is an amazing answer and a perfect reading of my situation.
I am using referenced models for reading lots of CAN messages from different ECUs, and the vendor made a scripts that automatically generates these Libraries that read the data.
I can't rework to put them all in one block.
I checked the MAAB guide and it seems that 63 Identifier length is ok, so I will go with this solution for the moment.
I still have to check with my compiler manual.
The funny thing is that I can't see the variables in any of the generated code, this is really strange, any clue how I could find them?
Maybe if I find them then I can find a way to generate the names so that they are unique even with 31 Identifier length.
Class hierarchies such as Input::IO::CAN::ReadMsg::CleanupRTR appear to be having the :: scope resolution operator transformed into _ characters, so when you see _ in the error messages, the first thing to try is substituting :: for each _ . Not fool-proof if the name itself happens to have _ in it, but should provide a starting place to look.

Sign in to comment.

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products

Release

R2019a

Asked:

on 26 Feb 2020

Commented:

on 19 Apr 2022

Community Treasure Hunt

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

Start Hunting!