AT&T 7300 C compiler/ variable name lengths (general)

rkl at ahuta.UUCP rkl at ahuta.UUCP
Wed Apr 10 04:26:43 AEST 1985

REFERENCES:  <9726 at brl-tgr.ARPA>

	There usually is a difference between what the C compiler accepts
as names and what the ASSEMBLER accepts as names.  In general I have found
that using only 7 character names is safest, ie. guarantees uniqness. Yes,
C is supposed to accept variable names with more that 8 chars, but the
assembler may not. For example, try two defining two variables names that
match for the first 7 chars but differ in the 8th, and compiling it. I have
found that the C compiler has no trouble with this but the assembler
prepends an underscore and truncates to 8 chars (so now the variable names
match), which of course causes 'compile' errors.

	I should mention that the above pertains to C compilers in general.

	Personally, I would stick to a maximum of 7 chars for a variable
name. I find long names very annoying and subject to typos. Yes this means
more cryptic names, but the solution is to put COMMENTS in your C code
(mini-flame: most C programs have extremely little in the way of comments).
In addition, shorter names will improve portability.

				R. Kevin Laux
				Software Vendor Tech Support
				ATTIS, Lincroft

More information about the Comp.lang.c mailing list