Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Maximum Function / Variable Name Identifier Length?

Reply
Thread Tools

Maximum Function / Variable Name Identifier Length?

 
 
David T. Ashley
Guest
Posts: n/a
 
      01-02-2007
I have this ugly habit of prefixing all function and variable names with
some identifying information about the owning module and perhaps also the
subcategory of function, i.e.

CGIX_ARBINT_sqrt();

In a few cases, these names have become rather long.

For both functions and variables, how long can I safely go without running
into the risk of two different names being treated the same by the compiler
or the linker? What standards apply?

The three compilers I use are:

a)gcc on x86/Linux.

b)MS VC++.

c)Cosmic's suite for microcontrollers.

Any insight or traceability to standards would be appreciated.

Dave.


 
Reply With Quote
 
 
 
 
jacob navia
Guest
Posts: n/a
 
      01-02-2007
David T. Ashley a crit :
> I have this ugly habit of prefixing all function and variable names with
> some identifying information about the owning module and perhaps also the
> subcategory of function, i.e.
>
> CGIX_ARBINT_sqrt();
>
> In a few cases, these names have become rather long.
>
> For both functions and variables, how long can I safely go without running
> into the risk of two different names being treated the same by the compiler
> or the linker? What standards apply?
>
> The three compilers I use are:
>
> a)gcc on x86/Linux.
>
> b)MS VC++.
>
> c)Cosmic's suite for microcontrollers.
>
> Any insight or traceability to standards would be appreciated.
>
> Dave.
>
>


The C standard guarantees in 5.2.4.1: Translation limits

<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
< end quote>

This are minimum requirements. gcc and msvc have
probably much more, but be careful with compilers for embedded systems.
 
Reply With Quote
 
 
 
 
=?utf-8?B?SGFyYWxkIHZhbiBExLNr?=
Guest
Posts: n/a
 
      01-02-2007
David T. Ashley wrote:
> I have this ugly habit of prefixing all function and variable names with
> some identifying information about the owning module and perhaps also the
> subcategory of function, i.e.
>
> CGIX_ARBINT_sqrt();
>
> In a few cases, these names have become rather long.
>
> For both functions and variables, how long can I safely go without running
> into the risk of two different names being treated the same by the compiler
> or the linker? What standards apply?


For C99, you can assume 31 significant characters for external names,
and 63 significant characters for internal and macro names. For C90, I
believe you can only assume 6 significant characters for external
names, and for internal and macro names I don't know. However, those
are the minimum limits. The exact limits are implementation-defined, so
you should be able to find those documented by your implementations.

 
Reply With Quote
 
aegis
Guest
Posts: n/a
 
      01-02-2007

Harald van Dijk wrote:
> David T. Ashley wrote:
> > I have this ugly habit of prefixing all function and variable names with
> > some identifying information about the owning module and perhaps also the
> > subcategory of function, i.e.
> >
> > CGIX_ARBINT_sqrt();
> >
> > In a few cases, these names have become rather long.
> >
> > For both functions and variables, how long can I safely go without running
> > into the risk of two different names being treated the same by the compiler
> > or the linker? What standards apply?

>
> For C99, you can assume 31 significant characters for external names,
> and 63 significant characters for internal and macro names. For C90, I
> believe you can only assume 6 significant characters for external
> names, and for internal and macro names I don't know. However, those
> are the minimum limits. The exact limits are implementation-defined, so
> you should be able to find those documented by your implementations.


c89 Says:

"The implementation shall treat at least the first 31 characters of
an internal name (a macro name or an identifier that does not have
external linkage) as significant. Corresponding lower-case and
upper-case letters are different. The implementation may further
restrict the significance of an external name (an identifier that has
external linkage) to six characters and may ignore distinctions of
alphabetical case for such names./10/ These limitations on identifiers
are all implementation-defined."

--
aegis

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSD Error: "Expecting '.', identifier or quoted identifier withmultiple tables. S_K ASP .Net 0 08-06-2008 09:22 PM
How can I fix the warning C4786 'identifier' : identifier wastruncated to 'number' characters in the debug information...? babakandme@yahoo.com C++ 2 12-11-2007 08:17 PM
identifier not found error, undeclared identifier aarthi28@gmail.com C++ 2 02-26-2007 02:11 AM
Trying to declare identifier locally and hide a file scope identifier Kobu C Programming 7 02-25-2005 05:19 AM
The number name 'System.Web.UI.WebControls' contains more than the maximum number of prefixes. The maximum is 3. mayur ASP .Net 2 07-02-2004 10:35 AM



Advertisments