Path: utzoo!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!magnus.ircc.ohio-state.edu!zaphod.mps.ohio-state.edu!think.com!hsdndev!spdcc!dirtydog!karl From: karl@ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: Tough stupid array question Message-ID: <1991Mar04.020619.22787@ima.isc.com> Date: 4 Mar 91 02:06:19 GMT References: <1991Feb27.054609.10792@nlm.nih.gov> <10362@dog.ee.lbl.gov> Sender: news@ima.isc.com (NEWS ADMIN) Reply-To: karl@ima.isc.com (Karl Heuer) Distribution: usa Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 20 In article <10362@dog.ee.lbl.gov> torek@elf.ee.lbl.gov (Chris Torek) writes: >[You need to use "foo(&iray)" to make the program type-correct] >(actually, given your defintion for DIM1 &c, it would probably be >clearer to write > for (i = 0; i < DIM1(*ray); ++i) Note that, if all mention of "ray" is via the construct "*ray" (I believe this is true given the above modification), it may be reasonable to use a reference rather than a pointer. C++ has builtin syntax for this; in C it can be emulated with a macro (using #undef to emulate scope): f(int (*ptr_ray)[5][1]) { #define jray (*ptr_ray) for (i = 0; i < DIM1(jray); ++i) ... jray[0][0] = ... #undef jray } This may clean up the perceived "ugliness" of the pointer-to-array code. Whether it's worth the added ugliness of the macro is a judgement call. Karl W. Z. Heuer (karl@ima.isc.com or uunet!ima!karl), The Walking Lint