home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / std / c / 2379 < prev    next >
Encoding:
Text File  |  1992-07-29  |  1.1 KB  |  33 lines

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!utcsri!utzoo!henry
  3. From: henry@zoo.toronto.edu (Henry Spencer)
  4. Subject: Re: Help with bit and byte addressable bitfields
  5. Message-ID: <Bs5s5w.4Ex@zoo.toronto.edu>
  6. Date: Wed, 29 Jul 1992 16:22:42 GMT
  7. References: <1992Jul26.043900.7020@gmuvax2.gmu.edu>
  8. Organization: U of Toronto Zoology
  9. Lines: 22
  10.  
  11. In article <1992Jul26.043900.7020@gmuvax2.gmu.edu> kbass@gmuvax2.gmu.edu (Ken Bass) writes:
  12. >typedef struct {
  13. >   unsigned int bit0;
  14. >         ...
  15. >   unsigned int bit32;
  16. >} WidgetRamImgDef;
  17. >
  18. >WidgetRamImgDef WidgetRamImg;
  19. >
  20. >I'd like to say WidgetRamImg=0x0; at init time, but the type is wrong.
  21.  
  22. There are no struct constants in ANSI C, and no way to make them.  What
  23. you have to do is declare a variable, say WidgetRamImgZero, of that type,
  24. initialize its fields individually to zeros, and then say
  25.  
  26.     WidgetRamImg = WidgetRamImgZero;
  27.  
  28. Note that if you make the zero variable global, the default initialization
  29. to zero will do the zeroing for you.
  30. -- 
  31. There is nothing wrong with making      | Henry Spencer @ U of Toronto Zoology
  32. mistakes, but... make *new* ones. -D.Sim|  henry@zoo.toronto.edu  utzoo!henry
  33.