473,757 Members | 10,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_sqr t();

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 microcontroller s.

Any insight or traceability to standards would be appreciated.

Dave.
Jan 2 '07 #1
3 15116
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_sqr t();

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 microcontroller s.

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_sqr t();

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_sqr t();

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
14946
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) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
58
10178
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 code... TCHAR myArray; DoStuff(myArray);
2
28599
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
5620
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
2021
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 it to be quite handy. Any thoughts? <script type="text/javascript"> function map(func) { var i,j,o; var results = ;
12
1467
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 original. def maximum(lst): maxval = lst for i in xrange(1, len(lst)): v = lst
5
1712
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 you have seen the rendered code) Basically I need the X buttons to change all the values of each textbox to zero either in the col or row depending on which button is clicked. Function summery: If you click on a X button on the right hand side of...
28
4336
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
3223
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 bastard so posting it before I forgot again... By taking this minimum code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head>
0
9489
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9298
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9737
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8737
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6562
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3829
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2698
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.