long identifiers

Kenneth J. Buck buck at granite.cr.bull.com
Sat Oct 27 02:02:12 AEST 1990


  others have written:
>>> [ .... ] [ from Henry Spencer's Ten Commandments... ]
>>>9.	Thy external identifiers shall be unique in the first six 
>>>	characters, though this harsh discipline be irksome and the 
>>>	years of its necessity stretch before thee seemingly without 
>>>	end, lest thou tear thy hair out and go mad on that fateful 
>>>	day when thou desirest to make thy program run on an old system.

This need not be a problem, IF your COMPILER supports long symbol names
(we're not talking about the linker here...).  Your code can have lots of
functions like:
   int long_function_name1 (stuff) ;
   int long_function_name2 (stuff) ;
   int long_function_name3 (stuff) ;
      . . .

and if you have a requirement that the external names be short, then include
a header file which redefines all the long names into short names, like:
   #define long_function_name1   aaaaa0
   #define long_function_name2   aaaaa1
   #define long_function_name3   aaaaa2
      . . .

This won't work if your compiler only supports short identifiers, but it will
be fine for the case whether the only restriction is the length of the
external names.  That way, you can write code with long function names, and
it can still be portable if necessary, by just remaping the names in the header
file.

Note: Some compilers use a name-mapping algorithm in order to achieve the
external symbol name-length restrictions, instead of just truncating the name
(something like, eliminate vowels starting from right to left, then
consonants, etc., until no more than 6 chars remain, or whatever...).



More information about the Comp.lang.c mailing list