MISRA Discussion Forums

Full Version: Rule #5.1 clarification
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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.