Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!leah!itsgw!steinmetz!uunet!iscuva!carlp From: carlp@iscuva.ISCS.COM (Carl Paukstis) Newsgroups: comp.lang.c Subject: Re: malloced structure initilization Message-ID: <2363@iscuva.ISCS.COM> Date: 17 Feb 89 00:10:49 GMT References: <202@sabin.UUCP> <8894@alice.UUCP> <1874@dataio.Data-IO.COM> <9649@smoke.BRL.MIL> Organization: ISC Systems Corporation, Spokane, WA Lines: 46 In article <9649@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >In article <1874@dataio.Data-IO.COM> bright@dataio.Data-IO.COM (Walter Bright) writes: >>Yah, and init_foo is guaranteed to be initialized to a 0 bit pattern, > >No, static storage is initialized to zero of the appropriate type, >which need not be a 0 bit pattern in all cases. The first few C >implementations could use 0-bit fill for zeros of all types; >other implementations may need the compiler to do something special >to meet this requirement. Now THIS is interesting! As I remember, the original discussion was about structures. Does this mean that if I write: #include static struct { float ward; int june; char wally; long beaver; double eddie; } mayfield; int main (int argc, char **argv) { printf("%f, %d, %c, %ld, %f\n", mayfield.ward, mayfield.june, mayfield.wally, mayfield.beaver, mayfield.eddie); return 0; } I'm GUARANTEED (at least by the ANSI standard) to get (something like): 0.0, 0, , 0, 0.0 even on "unusual" architectures where zero-bit-pattern != 0? Presumably that means that any pointers I mention in the structure are also set to proper nil pointers of appropriate type? Specifically, does the initialization of static variables to "zero of the appropriate type" apply to members of static structures? -- Carl Paukstis +1 509 927 5600 x5321 |"The right to be heard does not | automatically include the right UUCP: carlp@iscuvc.ISCS.COM | to be taken seriously." ...uunet!iscuva!carlp | - H. H. Humphrey