"array" vs. "&array" ?

Blair P. Houghton bph at buengc.BU.EDU
Sat Jan 13 03:09:46 AEST 1990


In article <21764 at mimsy.umd.edu> chris at mimsy.umd.edu (Chris Torek) writes:
>In article <CHUCKP.90Jan10103228 at halley.ncr-fc.FtCollins.NCR.com>
>chuckp at ncr-fc.FtCollins.NCR.com (Chuck Phillips) writes:
>>Granted.  But the question remains: "What is the compiler supposed to do when
>>the programmer askes for a pointer to something in the symbol table?"
>
>The language does not provide a means for the programmer to do such a
>thing (the language makes no statements about the internals of compilers,
>or even the existance of compilers, other than to require anything that
>pretends to implement C to follow some particular standard).

What Chris is trying to say (though I think he's been hanging around
with Doug and Daffy too long) is:

Usually when you ask for the pointer to an array you get a
pointer to the first element of the array.  While the
symbol table will hold the compiler's copy of the address
of the beginning of the array, the data in the array
obviously can not be stored in the symbol table.

E.g.:

	type_t *aptr, a[MAXINDEX+1];

	aptr = &a;

	if ( *aptr == a[0] )
	    puts( "Will always print this." );

I can't think of anything else in the symbol table that
would need to have its address taken, except maybe function
names, struct names, etc., which also have defined meanings
when the addressof operator is applied to them.  Taking the
address of a constant is an error.

				--Blair
				  "Luckily, I'm inconstant:
				   uunet!buengc!bph."



More information about the Comp.lang.c mailing list