MISRA Discussion Forums
5.1 in practice - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21)
+---- Forum: 8.5 Identifers (https://forum.misra.org.uk/forumdisplay.php?fid=160)
+---- Thread: 5.1 in practice (/showthread.php?tid=1426)



5.1 in practice - danielmarjamaki - 23-05-2018

I am not technically against 5.1. I just wonder how useful it is in practice.

Do you actually know a modern compiler that does not work well?

If you create a "too long" identifier will the modern compiler misbehave and create wrong code, or will they abort and complain to the user that an identifier is too long?

I created 2 external variables with 32000 characters and compiled with gcc and it seems to work fine.


Re: 5.1 in practice - misra-c - 08-06-2018

For clarification, the issue addressed by rule 5.1 is not the length of the external identifiers, but the number of significant characters in the identifier.

Even though you have found a compiler/linker with no obvious limit, this does not mean that other compiler/linkers do not have a limit. The gcc documentation states
"For external names, the number of significant characters are defined by the linker; for almost all targets, all characters are significant."

You will never violate rule 5.1 if your compiler/linker has no limit on the significant characters since the amplification for rule 5.1 states
Quote: This rule requires that different external identifiers be distinct within the limits imposed by the implementation