home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.dsp:3087 comp.lang.c:20172
- Newsgroups: comp.dsp,comp.lang.c
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: Is this a Legal Way to Access a Specific Address?
- Message-ID: <1993Jan25.170044.20283@taumet.com>
- Keywords: DSP, C, ANSI, Fixed RAM
- Organization: TauMetric Corporation
- References: <1993Jan23.042626.991@verdix.com> <1993Jan23.181029.29389@uvm.edu>
- Date: Mon, 25 Jan 1993 17:00:44 GMT
- Lines: 24
-
- >In article <1993Jan23.181029.29389@uvm.edu> wollman@sadye.emba.uvm.edu (Garrett Wollman) writes:
- >
- >The ANSI C standard
- >*does* guarantee (I believe, not having a copy handy) that there is
- >some flavor of integer that can be cast back and forth to a pointer
- >type.
-
- Not quite. It is legal to cast an integer value to a pointer type,
- and legal to cast a pointer value to an integer type. The results
- are implementation-defined, which means that such code is not portable.
-
- Further, it is not guaranteed that there exists an integer type which
- is large enough to contain all the bits in a pointer. For example,
- implementations with 48-bit pointers and 32-bit longs exist, and
- are allowed by the C Standard. Similarly, there are implementations
- where pointers cannot contain all possible integer values, and this
- is also allowed.
-
- Implementations commonly allow casting back and forth between ints
- (or longs) and pointers, but you have to check the compiler manual
- to see what is actually supported.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
-