home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.dsp:3110 comp.lang.c:20240
- 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: <1993Jan26.170719.22680@taumet.com>
- Keywords: DSP, C, ANSI, Fixed RAM
- Organization: TauMetric Corporation
- References: <1993Jan23.042626.991@verdix.com> <1993Jan24.171455.9451@bilver.uucp> <1k1pa3INNnl@elroy.jpl.nasa.gov>
- Date: Tue, 26 Jan 1993 17:07:19 GMT
- Lines: 30
-
- alan@elroy.Jpl.Nasa.Gov (Alan S. Mazer) writes:
-
- >In article <1993Jan23.042626.991@verdix.com> scotty@verdix.com (Scott R. Chilcote) writes:
- >>
- >>We're programming a device that has a RAM cache at address 809800H.
- >>Is it legal to address this memory in C as follows?
- >>#define ON_CHIP 0x809800
- >>...
- >> float *oc_ptr = (float *) ON_CHIP;
-
- >Excuse me, but the replies to this are getting silly. The poster doesn't
- >have an int. He has an integer constant. ...
- >There is simply an assignment. What he's proposing is fine.
-
- Sorry, no.
-
- A literal hexadecimal integer constant has type int or long, signed or
- unsigned, depending on its value and the ranges of those types.
- Assuming the value 0x809800 can be represented as type XINT, where XINT
- is one of the above types, the code has the same effect as
- XINT i = ON_CHIP;
- float *oc_ptr = (float *) i;
-
- In all such cases, an integer *value* is being cast to a pointer type.
- There are no literal pointer constants (except the null pointer) in C.
- The results of casting an integer value to a pointer type are
- implementation-defined and not portable.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
-