Date: Mon, 14 Dec 1998 23:46:30 -0500 (EST) From: Garrett Wollman <wollman@khavrinen.lcs.mit.edu> To: Mike Smith <mike@smith.net.au> Cc: Eivind Eklund <eivind@yes.no>, cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG Subject: Re: cvs commit: src/sys/i386/isa labpc.c Message-ID: <199812150446.XAA19758@khavrinen.lcs.mit.edu> In-Reply-To: <199812150420.UAA02573@dingo.cdrom.com> References: <19981215045111.B46780@follo.net> <199812150420.UAA02573@dingo.cdrom.com>
next in thread | previous in thread | raw e-mail | index | archive | help
<<On Mon, 14 Dec 1998 20:20:01 -0800, Mike Smith <mike@smith.net.au> said: > struct foo { > int a; > void *b; > }; > #define STRUCT_FOO_INIT {0, NULL} Much better to write this: static struct foo STRUCT_FOO_INIT; The Standard specifies that all objects with static lifetime are initialized AS IF each element were explicitly initialized to the integral constant zero. This means in particular that all pointers are initialized to a null pointer value, and all floating-point objects are initialized to the appropriate representation of the value zero. (Some values of GCC will generate suboptimal code for automatic structure initialization.) I often attempt use the following coding style: static const struct something null_something; int myfunc(args) { struct something my_something = null_something; /* do stuff with it... */ } However, from an efficiency standpoint, bzero will do just as well and is probably faster. -GAWollman -- Garrett A. Wollman | O Siem / We are all family / O Siem / We're all the same wollman@lcs.mit.edu | O Siem / The fires of freedom Opinions not those of| Dance in the burning flame MIT, LCS, CRS, or NSA| - Susan Aglukark and Chad Irschick To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199812150446.XAA19758>