473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Maximum Function / Variable Name Identifier Length?

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.
Jan 2 '07 #1
3 15047
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.
Jan 2 '07 #2
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.

Jan 2 '07 #3

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

Jan 2 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
2
by: Kums | last post by:
What is the maximum permissible size of a database? Is there any limitation. What is the maximum # of tablespace's allowed in a database? Thanks for your response.
42
by: baumann | last post by:
hi all, typedef int (*pfunc)(int , int); pfunc a_func; i know it's ok, but how can define a_func without typedef statement? thanks .
17
by: Matt Kruse | last post by:
Perl's map() function is a powerful shortcut to accomplish many "loop over an array and do X" operations. Below is a quick hack to simulate similar functionality. I've used it a few times and find...
12
by: Steve R. Hastings | last post by:
I was looking at a Python function to find the maximum from a list. The original was more complicated; I simplified it. The built-in max() function can replace the simplified example, but not the...
5
by: mk | last post by:
Greetings all - im new to this newsgroup so pls dont flame me :p I need some help! Please view the html below in a browser. Or goto this url -http://firebrain.co.uk/java-problem.htm (Assuming...
28
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
7
by: VK | last post by:
I was getting this effect N times but each time I was in rush to just make it work, and later I coudn't recall anymore what was the original state I was working around. This time I nailed the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.