Path: utzoo!attcan!uunet!munnari.oz.au!uhccux!ames!amdahl!vohra From: vohra@uts.amdahl.com (Pavan Vohra) Newsgroups: comp.lang.c Subject: offsetof() operator. A tricky question. Message-ID: <8ega02MX90Tk01@amdahl.uts.amdahl.com> Date: 10 Mar 90 12:42:30 GMT Reply-To: vohra@amdahl.uts.amdahl.com (KC) Organization: Amdahl Corporation, Sunnyvale CA Lines: 33 References: I would like to compile in the offsets of structure members. For example, with this structure struct astruct { int member0; char member1; } myastruct; I want to have, in the same program that the structure appears in, the number of bytes past myastruct where I can find member1. The application is an interpreter that will allow one to specify at run time the structure name and the member name, and to print the value of structure.member as a decimal or a string depending on its type. I will create an array with the offsets and names of the members and what structures they are members of. Once this part of the program is done I will want to write a program that creates the array. Do you think that that is a good way to do it? Has anybody implemented a virtual offsetof() compile-time operator, or an application similar to mine? I suppose symbolic debuggers do it all the time. -- --- Pavan Vohra Advanced Design Automation Technologies Amdahl Corporation {..hplabs|ames|decwrl}!amdahl!vohra Sunnyvale, CA 94086-3470 {vohra@uts.amdahl.com} ---