Path: utzoo!utgpu!water!watmath!clyde!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: Must the "switch" quantity be an integer? Message-ID: <9711@haddock.ima.isc.com> Date: 20 Oct 88 03:56:55 GMT References: <6137@june.cs.washington.edu> <8706@smoke.BRL.MIL> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 21 In article <8706@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >In article <6137@june.cs.washington.edu> pardo@cs.washington.edu (David Keppel) writes: >> #define BUFPTR ((os_t *)1) > >This is quite non-portable. ANSI C requires that there be some integral >type to which a pointer can be cast then uncast without loss of information, >but the integral type isn't necessarily int, and random integer values need >not be castable to pointers. True, except that "without loss of information" should be "and still compare equal to the original". You can lose information (e.g. runtime array bound checking), but nothing that the program would be depending on. >If you really have to have os_t*-shaped magic numbers, consider ... > #define BUFPTR (&dummy_buf) > case (ptrint_t)BUFPTR: C'mon Doug, you know better than that. That isn't a valid integral constant expression. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint