🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #154

Re: Help with bit and byte addressable bitfields

#154
From: Henry Spencer
Date: Wed, 29 Jul 1992 16:22
22 lines
1182 bytes
In article <1992Jul26.043900.7020@gmuvax2.gmu.edu> kbass@gmuvax2.gmu.edu (Ken Bass) writes:
>typedef struct {
>   unsigned int bit0;
>         ...
>   unsigned int bit32;
>} WidgetRamImgDef;
>
>WidgetRamImgDef WidgetRamImg;
>
>I'd like to say WidgetRamImg=0x0; at init time, but the type is wrong.

There are no struct constants in ANSI C, and no way to make them.  What
you have to do is declare a variable, say WidgetRamImgZero, of that type,
initialize its fields individually to zeros, and then say

	WidgetRamImg = WidgetRamImgZero;

Note that if you make the zero variable global, the default initialization
to zero will do the zeroing for you.
-- 
There is nothing wrong with making      | Henry Spencer @ U of Toronto Zoology
mistakes, but... make *new* ones. -D.Sim|  henry@zoo.toronto.edu  utzoo!henry
Technical Details
Message-ID: <Bs5s5w.4Ex@zoo.toronto.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!utcsri!utzoo!henry
References: <1992Jul26.043900.7020@gmuvax2.gmu.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!utcsri!utzoo!henry
From: henry@zoo.toronto.edu (Henry Spencer)
Subject: Re: Help with bit and byte addressable bitfields
Message-ID: <Bs5s5w.4Ex@zoo.toronto.edu>
Date: Wed, 29 Jul 1992 16:22:42 GMT
References: <1992Jul26.043900.7020@gmuvax2.gmu.edu>
Organization: U of Toronto Zoology
Lines: 22