MISRA Discussion Forums
Rule 5.1: typographical error? - 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: Rule 5.1: typographical error? (/showthread.php?tid=1087)



Rule 5.1: typographical error? - swestin - 30-07-2014

The amplification for this rule states:

Quote:In C99 the minimum requirement is that the first 31 characters of external identifiers are significant, with each universal character or corresponding extended source character occupying between 6 and 10 characters.

I think this is an error, and the statement should end as the parallel statement for Rule 5.2:

Quote:In C99 the minimum requirement is that the first 31 characters of external identifiers are significant, with each universal character or corresponding extended source character counting as a single character.

Is this correct?

-Stephen H. Westin
GrammaTech, Inc.


Re: Rule 5.1: typographical error? - misra-c - 13-08-2014

The difference in the wording is intentional and is based on the wording in the translation limits section 5.2.4.1 of the C99 standard.
Quote: - 63 significant initial characters in an internal identifier or a macro name (each universal character name or extended source character is considered a single character)

- 31 significant initial characters in an external identifier (each universal character name specifying a short identifier of 0000FFFF or less is considered 6 characters, each universal character name specifying a short characters identifier of 00010000 or more is considered 10 characters, and each extended source character is considered the same number of characters as the corresponding universal character name, if any)
An internal identifier is never visible outside the translation unit in which it is declared. It is therefore not necessary to worry about external representation issues and it is possible to count each universal character name as one character. In contrast, information on externally visible identifiers needs to be compared against identifiers declared in other translation units. The values of 6 and 10 were chosen so that the encodings \u1234 and \U12345678 could be used.