home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / dsp / 3110 < prev    next >
Encoding:
Text File  |  1993-01-27  |  1.6 KB  |  43 lines

  1. Xref: sparky comp.dsp:3110 comp.lang.c:20240
  2. Newsgroups: comp.dsp,comp.lang.c
  3. Path: sparky!uunet!taumet!steve
  4. From: steve@taumet.com (Steve Clamage)
  5. Subject: Re: Is this a Legal Way to Access a Specific Address?
  6. Message-ID: <1993Jan26.170719.22680@taumet.com>
  7. Keywords: DSP, C, ANSI, Fixed RAM
  8. Organization: TauMetric Corporation
  9. References: <1993Jan23.042626.991@verdix.com> <1993Jan24.171455.9451@bilver.uucp> <1k1pa3INNnl@elroy.jpl.nasa.gov>
  10. Date: Tue, 26 Jan 1993 17:07:19 GMT
  11. Lines: 30
  12.  
  13. alan@elroy.Jpl.Nasa.Gov (Alan S. Mazer) writes:
  14.  
  15. >In article <1993Jan23.042626.991@verdix.com> scotty@verdix.com (Scott R. Chilcote) writes:
  16. >> 
  17. >>We're programming a device that has a RAM cache at address 809800H.
  18. >>Is it legal to address this memory in C as follows?
  19. >>#define ON_CHIP 0x809800
  20. >>...
  21. >>   float *oc_ptr = (float *) ON_CHIP;
  22.  
  23. >Excuse me, but the replies to this are getting silly.  The poster doesn't
  24. >have an int.  He has an integer constant.  ...
  25. >There is simply an assignment.  What he's proposing is fine.
  26.  
  27. Sorry, no.
  28.  
  29. A literal hexadecimal integer constant has type int or long, signed or
  30. unsigned, depending on its value and the ranges of those types.
  31. Assuming the value 0x809800 can be represented as type XINT, where XINT
  32. is one of the above types, the code has the same effect as
  33.     XINT i = ON_CHIP;
  34.     float *oc_ptr = (float *) i;
  35.  
  36. In all such cases, an integer *value* is being cast to a pointer type.
  37. There are no literal pointer constants (except the null pointer) in C.
  38. The results of casting an integer value to a pointer type are
  39. implementation-defined and not portable.
  40. -- 
  41.  
  42. Steve Clamage, TauMetric Corp, steve@taumet.com
  43.