Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!decwrl!decvax!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: A nice macro Message-ID: <13788@haddock.ima.isc.com> Date: 21 Jun 89 17:03:51 GMT References: <2784@solo8.cs.vu.nl> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 11 In article <2784@solo8.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes: >C arrays always begin with subscript 0. ... the solution below seems so >straightforward: > bar _foo[HIGH - LOW + 1]; > #define foo (_foo - LOW) If LOW <= 0 <= HIGH, no problem. But this is not portable if you're trying to emulate, say, origin-1 arrays (LOW==1), since the expression (_foo-1) could be outside your address space. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint