"array" vs. "&array" ?

Gary L. Randolph randolph at ektools.UUCP
Thu Jan 4 01:03:14 AEST 1990


In article <1989Dec28.100415.17825 at eng.umd.edu> dskim at eng.umd.edu (Daeshik Kim) writes:
>In article <21419 at mimsy.umd.edu> chris at mimsy.umd.edu (Chris Torek) writes:
>>
>>	&arr
>>
>>produces either a warning (Classic C), or a value of type `pointer
>>to array SIZE of basetype' (New C).
>>
>>
>>>	p = &a;
>>
>>Unfortunately, when handed to an Old C compiler, you get:
>>
>>>warning: & before array or function: ignored
>>>warning: illegal pointer combination, op =
>>
>
>	If I define "char a[10];" and use " &a" (e.g. address of array a)
>	, isn't this undefined?

***>    That depends upon which generation of C compiler you are using!!!
***>    Unfortunately, there are *THREE* reactions a C compiler may have
***>    to taking the address of an array name.

***>     1.) Compilers strictly conformant to K&R C will generate an error
***>         to indicate that &array_name is undefined.
***>     2.) Since the novice C programmer made this mistake so frequently,
***>         compiler vendors 'got nice' and simply generated a warning and
***>         informed you that the '&' was ignored. (How kind!?)
***>     3.) ANSI extended the language definition to allow taking the 
***>         address of an array name, so an ANSI conformant compiler will
***>         now (correctly) yield pointer to array of T, or pointer to
***>         pointer to T.

***>    IMHO, this extension is reasonable, though I have not found a place
***>    for it in the applications on which I have worked.


           Gary



More information about the Comp.lang.c mailing list