A nice macro

Karl Heuer karl at haddock.ima.isc.com
Thu Jun 22 03:03:51 AEST 1989


In article <2784 at solo8.cs.vu.nl> maart at 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 at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list