Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ecr1.UUCP Path: utzoo!hcrvax!ecrhub!ecr1!peterc From: peterc@ecr1.UUCP (Peter Curran) Newsgroups: net.lang.c Subject: Re: Address of array Message-ID: <194@ecr1.UUCP> Date: Tue, 25-Mar-86 09:27:42 EST Article-I.D.: ecr1.194 Posted: Tue Mar 25 09:27:42 1986 Date-Received: Thu, 27-Mar-86 05:04:42 EST References: <422@umcp-cs.UUCP> Organization: Emerald City Research Inc., Toronto Lines: 62 Relay-Version: version B 2.10.1 6/24/83; site ecr1.UUCP Path: ecr1!ecrhub!hcrvax!utzoo!watmath!clyde!cbosgd!gatech!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: Address of array Message-ID: <422@umcp-cs.UUCP> Date: Fri, 21-Mar-86 07:04:26 EST Date-Received: Tue, 25-Mar-86 04:33:12 EST References: <750@abic.UUCP> <211@dg_rtp.UUCP> <685@steinmetz.UUCP> <58@paisley.ac.uk> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 53 Chris Torek writes (in reply to Robert Hamilton's reply to Wayne Throop): > I think you missed the point. Suppose you write the following: > > #include "../projlib/types.h" > > x_type variable; > > f() > { > g(&variable); > ... > } > > g(p) > x_type *p; > { > x_type newvalue; > > ... > *p = newvalue; > ... > } > > This looks perfectly reasonable, and works quite well if `x_type' > is a name for a simple type, a structure, or a union. It does not > work---indeed, it does not even compile---if `x_type' is a name > for an array. The problem is that you are not `allowed' to know > just what `x_type' really is. > > As it turns out, it is not often useful to write something like > the above if `x_type' is a name for an array, and this problem does > not seem to come up in practice---or at least I have not seen it. > And if all else fails one can always wrap the array in a structure: > > typedef struct { > int x_val[10]; > } x_type; This situation does occur - in connection with longjmp/setjmp. The functions are passed a variable of type 'jmp_buf'. In fact, the functions expect an address. With most compilers, 'jmp_buf' is an array, and naming it produces an address. On a few compilers, the 'jmp_buf' is a structure (which makes more sense), but you must pass its address (i.e. using the '&' operator). One more portability hiccup. -- Peter Curran Emerald City Research, Ltd. ...utzoo!ecrhub!ecr1!peterc