site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com -R (2) The reason for using the '8' was: (a) to ensure that strange compiler-specific alignment and packing rules didn't come into play with a static structure alignment and padding by using a "natural" boundary (look up "#pragma pack"). (b) because a non-0 value is in technical compliance with the c99 standard, so the compiler guys can't argue it's illegal. It is someone sticking their tongue out at compiler folks who strictly enforce standards at the cost of making otherwise perfectly good older code fail to run. The same argument happened over the "volatile" keyword. (c) The '8' has nothing to do with the structure size or 32 vs. 64 bits, it's just a coincidence, if you assume 32 bits and 4 byte alignment of internal structure fields when structure packing. -- Terry _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... On Jun 24, 2010, at 8:31 AM, Arnab Ganguly wrote: To be more precise.I am curious to know what is the concept of behind calling ((Test *) 8)->a -8 or sometime ((Test *) 16)->a -16.Does it have any dependency with the number members present in the structure or how is it ?Also how things are to be handled in case of OS 64bit. On Thu, Jun 24, 2010 at 6:44 PM, Arnab Ganguly <aganguly01@gmail.com> wrote: Hi All, Thanks for all help and inputs.Got the idea of offsetof() .But unfortunately not clear about what is the concept of 8 and then again subtracting for 8.Like when will i do 16 and -16 etc? Please help. -A (1) I sent my original reply to you off list precisely to avoid this kind of noise on the list. It's also impolite to quote private email to a mailing list. Please send any additional follow up questions on this subject to the comp.lang.c Usenet group, or to some other mailing list. The relevance to porting code using the construct to Mac OS X has been answered already, so additional questions no longer get the benefit of the doubt about being Mac OS X related. This email sent to site_archiver@lists.apple.com
participants (1)
-
Terry Lambert