typedef gripe

warren warren at tikal.UUCP
Wed Oct 10 08:32:34 AEST 1984


[There are no bugs]

	It seems to me that typedef'ing something to an array uncovers
	some ambiguity in the C language, in that array names are
	constants, not variables.  Typedef'ing to a constant is rather
	odd to begin with.  One feels it perhaps ought to be illegal.
	Or at least very rude.  For example, would you accept
	"typedef 7 foo;" ?

	Array names are "pointer constants" of the type of "pointer to
	the first element of the array".  Other languages and machines
	used to call this sort of thing an "address constant".

	Of course, there is an inconsistancy.  The "sizeof(arrayname)"
	expression is the number of bytes in all the elements of the
	array.  Furthermore, when an arrayname is passed as the actual
	argument to a function, the formal function argument (in the
	function) has some other size entirely.  On machines that
	do not address a byte directly, the number of bytes in array
	of pointers or of floating point constants does not even
	have to be an integer !  

					teltone!warren



More information about the Comp.lang.c mailing list