public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Number of significant characters in identifiers
@ 2011-05-25  6:03 Jeffrey D. Cherry
  2011-05-25  6:44 ` Jonathan Wakely
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jeffrey D. Cherry @ 2011-05-25  6:03 UTC (permalink / raw)
  To: gcc-help

Greetings -

We are evaluating some C code based on MISRA C:2004 standards, which 
state that "Identifiers (internal and external) shall not rely on the 
significance of more than 31 characters."  The code uses a lot of 
internal identifiers that exceed the 31 character limit.  The code is 
compiled with an old version of gcc, specifically version 2.96.  From 
the documentation of the current version of gcc, we know that for all 
internal names, all characters are significant.  Was this also the case 
for the older version of the compiler, even for the venerable old 
version 2.96?  If so, is there some document that states this?  (I can't 
find documentation that goes back to this old a version of the gcc.)  
Thanks in advance for any help you can provide.

-- 
Regards,

Jeffrey D. Cherry
RSSA Technical Manager
Senior Software Engineer/Analyst
ACTA SC


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Number of significant characters in identifiers
  2011-05-25  6:03 Number of significant characters in identifiers Jeffrey D. Cherry
@ 2011-05-25  6:44 ` Jonathan Wakely
  2011-05-25  8:21 ` Ian Lance Taylor
  2011-05-25 17:58 ` Henderson, Stuart
  2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2011-05-25  6:44 UTC (permalink / raw)
  To: Jeffrey D. Cherry; +Cc: gcc-help

On 24 May 2011 21:26, Jeffrey D. Cherry wrote:
> Greetings -
>
> (I can't find documentation that goes back to
> this old a version of the gcc.)

Maybe because there was no GCC 2.96 release, that version number was
used by various third-party vendors shipping a fairly heavily-patched
GCC.

You can find docs for the 2.95.3 release at http://gcc.gnu.org/onlinedocs/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Number of significant characters in identifiers
  2011-05-25  6:03 Number of significant characters in identifiers Jeffrey D. Cherry
  2011-05-25  6:44 ` Jonathan Wakely
@ 2011-05-25  8:21 ` Ian Lance Taylor
  2011-05-25 17:58 ` Henderson, Stuart
  2 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2011-05-25  8:21 UTC (permalink / raw)
  To: Jeffrey D. Cherry; +Cc: gcc-help

"Jeffrey D. Cherry" <jeff.cherry@actasc.com> writes:

> We are evaluating some C code based on MISRA C:2004 standards, which
> state that "Identifiers (internal and external) shall not rely on the
> significance of more than 31 characters."  The code uses a lot of
> internal identifiers that exceed the 31 character limit.  The code is
> compiled with an old version of gcc, specifically version 2.96.  From
> the documentation of the current version of gcc, we know that for all
> internal names, all characters are significant.  Was this also the
> case for the older version of the compiler, even for the venerable old
> version 2.96?  If so, is there some document that states this?  (I
> can't find documentation that goes back to this old a version of the
> gcc.)  Thanks in advance for any help you can provide.

The gcc compiler has never put any limit on the number of significant
characters in an identifier.  I don't know whether this was ever
documented.

What matters here, though, is not gcc, but the assembler and linker.
Those are not part of gcc.  Some assemblers and linker limit the length
of externally visible symbols.  The GNU assembler and linker have never
had any limits, though.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Number of significant characters in identifiers
  2011-05-25  6:03 Number of significant characters in identifiers Jeffrey D. Cherry
  2011-05-25  6:44 ` Jonathan Wakely
  2011-05-25  8:21 ` Ian Lance Taylor
@ 2011-05-25 17:58 ` Henderson, Stuart
  2 siblings, 0 replies; 4+ messages in thread
From: Henderson, Stuart @ 2011-05-25 17:58 UTC (permalink / raw)
  To: Jeffrey D. Cherry, gcc-help

>We are evaluating some C code based on MISRA C:2004 standards, which
>state that "Identifiers (internal and external) shall not rely on the
>significance of more than 31 characters."  The code uses a lot of
>internal identifiers that exceed the 31 character limit.  The code is
>compiled with an old version of gcc, specifically version 2.96.  From
>the documentation of the current version of gcc, we know that for all
>internal names, all characters are significant.  Was this also the case
>for the older version of the compiler, even for the venerable old
>version 2.96?  If so, is there some document that states this?  (I can't
>find documentation that goes back to this old a version of the gcc.)
>Thanks in advance for any help you can provide.

I don't think it matters how many characters GCC (or ld/gas) considers significant, the rule (5.1) states that the limit shall not be exceeded even if the compiler supports it.  The limit is in place to ensure code portability and readability.

However, it is important to make the distinction that the rule doesn't outlaw identifiers that are >31 characters.  It outlaws identifiers that are significant beyond 31 characters.  for example:

//this would be a breach of misra 5.1 as the 32nd character is significant (ie. the first 31 characters of each identifier are not unique):
uint32_t identifieris30characterstohere1abcdefg;
uint32_t identifieris30characterstohere1bbcdefg;

//this, however, is fine:
uint32_t identifieris30characterstohere1abcdefg;
uint32_t identifieris30characterstohere2bbcdefg;

The reason being that the identifier is unique within the first 31 characters.  Anything after the 31st character is essentially chopped off.

If none of the >31 character identifiers in your code share the same first 31 chars, then it is Misra compliant.


        Stuart Henderson
        Software Development Engineer
        ADI Edinburgh Design Centre
        Analog Devices Ltd

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-25 17:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-25  6:03 Number of significant characters in identifiers Jeffrey D. Cherry
2011-05-25  6:44 ` Jonathan Wakely
2011-05-25  8:21 ` Ian Lance Taylor
2011-05-25 17:58 ` Henderson, Stuart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).