home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16756 < prev    next >
Encoding:
Internet Message Format  |  1992-11-18  |  1.7 KB

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!swrinde!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!uwm.edu!biosci!agate!stanford.edu!leland.Stanford.EDU!dkeisen
  2. From: dkeisen@leland.Stanford.EDU (Dave Eisen)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Pointer to a short struct????
  5. Message-ID: <1992Nov18.234947.7227@leland.Stanford.EDU>
  6. Date: 18 Nov 92 23:49:47 GMT
  7. References: <1eeeeiINNae6@rave.larc.nasa.gov>
  8. Sender: news@leland.Stanford.EDU (Mr News)
  9. Distribution: usa
  10. Organization: Sequoia Peripherals, Inc.
  11. Lines: 29
  12.  
  13. In article <1eeeeiINNae6@rave.larc.nasa.gov> alan@hal.larc.nasa.gov (alan dare) writes:
  14. >
  15. >    I am mapping (mmap) a board that pulls information from an external
  16. >data bus into my programs address space. The data is in a packed format. 
  17. >Instead of using shifts and masks to extract the data I planed on using bit 
  18. >fields. 
  19.  
  20. >The million dollar question is: Is it possible 
  21. >to have a structure smaller than a full word, like a short? If so whats
  22. >the declaration?
  23.  
  24.  
  25. This is *heavily* system dependent. On SCO Xenix you can by
  26. specifying with a pragma that the compiler pack a given
  27. structure. Check the manual for your compiler. It might have
  28. something similar.
  29.  
  30. But even if it does, I don't recommend doing this. There are
  31. almost no guarantees about how bitfields behave. They certainly
  32. aren't well enough controlled to make them appropriate for
  33. modeling devices. Stick with shifts and masks.
  34.  
  35.  
  36.  
  37. -- 
  38. Dave Eisen                               Sequoia Peripherals: (415) 967-5644
  39. dkeisen@leland.Stanford.EDU              Home:                (415) 321-5154
  40.        There's something in my library to offend everybody. 
  41.           --- Washington Coalition Against Censorship
  42.