MISRA Discussion Forums
Rule #5.1 clarification - 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: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17)
+---- Forum: 6.5 Identifiers (https://forum.misra.org.uk/forumdisplay.php?fid=32)
+---- Thread: Rule #5.1 clarification (/showthread.php?tid=926)



Rule #5.1 clarification - gs - 10-12-2012

Hi,
The conversation at http://www.misra.org.uk/forum/viewtopic.php?f=61&t=508 states identifiers longer than 31 characters are permitted. However, the exemplar suite suggest such identifiers are, per se, prohibited. Which is correct?


Re: Rule #5.1 clarification - misra-c - 20-12-2012

Rule 5.1, as clarified by TC1, requires identifiers to be distinct in the first 31 characters across all namespaces. Identifiers that are longer than 31 characters are indeed permitted provided that they are distinct in the first 31 characters.

The examples of non-compliance in the exemplar suite are intended to support this view. For example, lines 43 and 44 of mc2_0501_1.h read:

Code:
extern int32_t name_68_xvxv_xxxxxxxxxxxxxxxx31a;        /* Not Compliant */
extern int32_t name_68_xvxv_xxxxxxxxxxxxxxxx31b;        /* Not Compliant */

These identifiers are non-compliant because they do not differ from each other in the first 31 characters. If there are any examples of identifiers that are non-compliant purely because of their length, please report their location so that we can investigate further.

Note that the minimum requirement on a conforming implementation with regard to external identifiers is to support up to 6 significant characters without regard to their case. In practice most implementations support a higher number of characters and distinguish between case of external identifiers but this should be confirmed if it is being relied on.