site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com User-agent: Thunderbird 2.0.0.24 (X11/20100411) Dear All, Sorry for posting a basic C question.Below is the code base. struct Test { int a; int b; }; //member offset. int result = (((Test *) 8)->a) - 8; I get bus error for this. I am not clear about the logic as what exactly ((Test *) 8)->a signifies here and why -8 is done. I have copy pasted a smaller portion of the main code.Only one line written as Member offset. The above code works fine in 32bit but in 64bit I am getting issue if I can understand the above logic will be more clear as what needs to be done. Use offsetof() http://en.wikipedia.org/wiki/Offsetof _______________________________________________ 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... This is a classic case of trying to implement offsetof() as Peter suggested , but having platform dependent behavior . This follows from the below idiomatic construct of offsetof() implementation: #define offsetof(type, field) ((size_t)((char *)&((type *)0)->field - (char *)(type *)0)) Portable 'C' code should instead use the platform offsetof() implementations available . Peter O'Gorman wrote: On 06/23/2010 09:53 AM, Arnab Ganguly wrote: Peter _______________________________________________ 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/rohitash.panda%40oracle.co... This email sent to rohitash.panda@oracle.com This email sent to site_archiver@lists.apple.com